1. Go to this page and download the library: Download tamedevelopers/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/ */
tamedevelopers / validator example snippets
use \Tamedevelopers\Validator\Validator;
$form = new Validator();
public function save(Request $request){
$form = new Validator();
or
$form = form();
}
$form->rules([
"string|country|==|0" => 'Please Select a Country',
"email:email" => 'Please enter a valid email address',
])
$form->rules([
"s:name" => 'Please enter a name',
])->validate(function($response){
$response->param; //Collection of form data
$response->getMessage(); //message property
});
$form->rules([
"s:name" => 'Please enter a name',
])->save(function(){
//on success
});
$form->rules([
"s:password" => 'Please enter a name',
"s:retype_pass:!==:{$form->old('password')}" => 'Password mismatch, Please enter same password',
]);
$form->rules([
"string:country:==:0" => 'Please Select a Country',
"email:email" => 'Please enter a valid email address',
])->save(function($response){
$param = $response->param;
$param->country;
$param['country']
// As you can see, we're able to access data in both ways without errors
});