TinyValidator is a tiny validation package. Read the documentation.
If you have Composer, just include TinyValidator as a project dependency in your composer.json
. If you don't just install it by downloading the .ZIP file and extracting it to your project directory.
require: {
"tinylara/tinyvalidator": "*"
}
$data = ['title'=>'你', 'email'=>'1@baiducom'];
$rules = [
'title' => 'required|min:3|max:255',
'email' => 'required|email',
];
$validator = new \TinyLara\TinyValidator\TinyValidator($data, $rules);
if ( !$validator->success ) {
foreach ($validator->errors as $error) {
echo $error.'<br>';
}
}
The TinyValidator is open-sourced software licensed under the MIT license.