dev-master
9999999-dev https://github.com/GabrielJMJ/simple-validatorTo simple validations in PHP.
MIT
The Requires
- php >=5.3.0
library
Wallogit.com
2017 © Pedro Peláez
To simple validations in PHP.
To simple validations in PHP., (*2)
{
"psr-4": {
"SimpleValidator\\": "vendor/gabrieljmj/simple-validator/lib/SimpleValidator/"
}
}
require_once SIMPLE_VALIDATOR_DIR . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . 'autoload.php'
The implementation will be in a chain, where you'll show what the next validation for that element., (*3)
This is the exception that is thrown when one validation to fail and the exception are enabled., (*4)
SimpleValidatorException::getInvalidParameterName()
Return what validation failure, (*5)
Arr Verify if element is an arrayBoolean Verify if element is a booleanCallable Verify if element is a callableCpf Verify if element is a CpfDirectory Verify if element is a directoryDouble Verify if element is a dubleEmail Verify if element is an emailEqual Verify if element is equal to anotherFile Verify if element is a fileFloat Verify if element is a floatFunc Verify if element is a functionInt Verify if element is an integerLenght Verify if element is the specified sizeMaximumLenght Verify if element have the maximum specified sizeMethod Verify if element is a class's methodMinimumLenght Verify if element have the minimum specified sizeNotEmpty Verify if element is not emptyNull Verify if element is nullNumeric Verify if element is numericObject Verify if element is an objectString Verify if element is a stringUrl Verify if element is an URLuse SimpleValidator\Validator\NotEmpty;
use SimpleValidator\Validator\Url;
use SimpleValidator\Exception\SimpleValidatorException;
//...
$url = 'http://example.com';
$validator = new NotEmpty; // verify if string is not empty
$validator->setSucessor( new Url ); // verify if string is an URL
try{
$validator->validate( $url, true ); // realize all validations predefined
}catch( SimpleValidatorException $e ){
echo '<b>Error:</b> ' . $e->getMessage() . '<br /> <b>On test:</b> ' . $e->getInvalidParameterName();
}
use SimpleValidator\Validator\NotEmpty;
use SimpleValidator\Validator\Url;
//...
$url = 'http://example.com';
$validator = new NotEmpty; // verify if string is not empty
$validator->setSucessor( new Url ); // verify if string is an URL
if( $validator->validate( $url ) ){ // realize all validations predefined
//Success
}{
//Fail
}
To simple validations in PHP.
MIT
library