1. Go to this page and download the library: Download inani/phpvalidate 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/ */
inani / phpvalidate example snippets
$validator = new Validator([ 'name' => 'Inani El Houssain']);
// Only if ->addRule(( new Rule('name'))->
$bool = $validator->check();
// get the errors of the name field, all the fields if not specified
$validator->getErrors('name');
use Inani\PHPValidate\CustomConstraint;
class ShouldBeAnEmail extends CustomConstraint
{
/**
* Check if the field is Required
*
* @param null $value
* @return bool
*/
public function isValid($value = null)
{
if(!filter_var($value, FILTER_VALIDATE_EMAIL)){
$this->errorFound();
return false;
}
return true;
}
public function getError()
{
return "This is not a valid email";
}
}
$validator->addRule(( new Rule('email'))->
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.