/form

📝 Leaf form module

Primary LanguagePHP



Leaf Form Module



Latest Stable Version Total Downloads License

Leaf's form validation functionality packaged as a serve-yourself module.

Installation

You can easily install Leaf using the Leaf CLI:

leaf install form

Or via Composer.

composer require leafs/form

Basic Usage

<?php

$data = [
  'name' => [
    'first' => 'Jane',
    'last' => 'Doe',
  ],
  'email' => 'example@example.com',
  'password' => 'password1234',
];

$validated = form()->validate($data, [
  'name' => 'array()',
  'name.first' => 'required',
  'name.last' => 'required',
  'email' => 'required|email',
  'password' => 'required|min:8'
]);

if ($validated) {
  // do something
} else {
  // get errors
  $errors = form()->errors();
}