1. Go to this page and download the library: Download genai/validation library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
genai / validation example snippets
use GenAI\Validation\Attribute\Validate;
use GenAI\Validation\Attribute\NotBlank;
use GenAI\Validation\Attribute\Email;
use GenAI\Validation\Attribute\Length;
use GenAI\Validation\Attribute\Matches;
#[Validate]
class SignupForm
{
#[NotBlank] public $name;
#[NotBlank] #[Email] public $email;
#[Length(min: 6)] public $password;
#[Matches('password')] public $passwordConfirm;
}
// bind() populates declared fields from the request (public prop set directly,
// private via its setXxx() — where the form can normalize), then validate().
$form = $validator->bind(new SignupForm(), $request->getParsedBody());
$errors = $validator->validate($form); // array('email' => 'Please enter a valid email address.')
if (!$errors) {
// valid — use $form->getEmail(), etc.
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.