PHP code example of assegaiphp / validation
1. Go to this page and download the library: Download assegaiphp/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/ */
assegaiphp / validation example snippets
use Assegai\Validation\Validator;
$validator = new Validator();
$isValid = $validator->validate($value, '
use Assegai\Validation\Interfaces\IValidationRule;
class MyCustomValidationRule extends IValidationRule
{
public function passes(mixed $value): bool
{
// validate the value
}
public function getErrorMessage(): string
{
return 'The value is invalid.';
}
}
if (!$isValid)
{
$errors = $validator->getErrors();
// handle errors
}