1. Go to this page and download the library: Download xtompie/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/ */
Validation::of($input)
/* Group 1 */
->group()
/* Group 2 */
->group()
/* Group 3 */
;
Validation::new()
->main() // validation will target main subject
->property($name) // when subject is an object, will target property named $name
->method($name) // when subject is an object, will target getter method named $name
->key($key) // when subject is an array, will target array value where key is $key
->take($callback) // custom target $callback, as first argument main subject will be given
;
Validation::new()
->key('name')
// raw validator, validator return Result
->validator(fn ($value) => strlen($value) !== 13 ? Result::ofSuccess() : Result::ofErrorMsg('Length can not be 13'))
// custom callback
->callback(fn ($value) => strlen($value) !== 13, 'Length can not be 13')
->notBlank('Fill name!')
;