1. Go to this page and download the library: Download wepesi/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/ */
wepesi / validation example snippets
$valid = new \Wepesi\App\Validate();
$schema = new \Wepesi\App\Schema();
$source = [];
$rules = ["name" => $schema->string()->min(3)->max(5)->generate()];
$valid->check($source,$rules);
"email"=>$schema->string()->email()->min(9)->max(50)->ing : type of the value to be checked should be a string
// - email : that string should be an email
// - min=>9 : the email should have minimum of 9 character
// - max=>50 : the email should have maximum of 50 characters
// -
$source=[
"name"=>"wepesi",
"email"=>"[email protected]",
"link"=>"https://github.com/bim-g/wepesi_validation/",
"age"=>1
];
$validate = new \Wepesi\App\Validate();
$schema = new \Wepesi\App\Schema();
$rules = [
"name"=>$schema->any(),
"email"=>$schema->string()->/ return an array with different related errors
$schema = [
"names" => $schema->array()->min(1)->max(10)->string()->generate();
"ages" => $schema->array()->min(2)->max(5)->number()->generate()
]
// name should be an array and should have a minimum of 1 element and maximum should be 10, each element should be a type string
// ages should be an array and should have a minimum of 2 elements and does not exceed 5, each element should be a type number