PHP code example of flikore / validator
1. Go to this page and download the library: Download flikore/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/ */
flikore / validator example snippets
validation stuff
idation stuff
likore\Validator\Validators as v;
// Instantiate an existing validator
$v = new v\ExactValueValidator(5);
// Use the "validate" method to check if a value is valid
var_dump($v->validate(5)); // bool(true)
// And you can use the same validator object as many times as you want
var_dump($v->validate(4)); // bool(false)
var_dump($v->validate(0)); // bool(false)
likore\Validator\Validators as v;
class PerfectSquareValidator extends Flikore\Validator\Validator
{
protected function doValidate($value)
{
return is_numeric($value) && (floor(sqrt($value)) * floor(sqrt($value))
== ((int)$value));
}
}
$v = new PerfectSquareValidator();
var_dump($v->validate(25)); // bool(true)
var_dump($v->validate(30)); // bool(false)
var_dump($v->validate('36')); // bool(true)