1. Go to this page and download the library: Download apolinux/validator 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/ */
apolinux / validator example snippets
$rules = [
'name' => 'is_alnum' , // php function
'address' => 'defined' , // internal validator
'user' => [ 'regex' => '/\w+/' , 'is_int' => null , ...] ,//rules defined in array
'phone' => ['method' => '\namespace\subnamespace\Classname::validationMethod' ..]
'fieldname5'=> 'defined|is_int|min:3|max:20', // several rules in one line separated by '|'
...
]
$validator = new Apolinux\Validator ;
if( ! $validator->validate($rules) ){
throw new \Exception('There is an error with input:' . $validator->getLastError()) ;
}
$rules = [
'name' => function($input, $value, &$message){
//validate data
if(validation_failed){
return false ;
}
// no error in validation
return true ;
},
...
] ;
$rules = [
'field_name1' => 'is_double' , // PHP function
'field_name2' => 'user_defined_function', // custom function
...
] ;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.