leafs/form

Simple straightup data validation

v2.1 2023-11-12 21:51 UTC

This package is auto-updated.

Last update: 2024-02-12 23:29:12 UTC


README



68747470733a2f2f6c6561667068702e6e65746c6966792e6170702f6173736574732f696d672f6c656166332d6c6f676f2e706e67

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();
}