gabrieljmj / simple-validator
This package is abandoned and no longer maintained.
No replacement package was suggested.
To simple validations in PHP.
dev-master
2014-07-29 17:07 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2022-02-01 12:35:34 UTC
README
To simple validations in PHP. ##Autoload ####Via composer
{ "psr-4": { "SimpleValidator\\": "vendor/gabrieljmj/simple-validator/lib/SimpleValidator/" } }
####Autoload file
require_once SIMPLE_VALIDATOR_DIR . DIRECTORY_SEPARATOR . 'autoload' . DIRECTORY_SEPARATOR . 'autoload.php'
##Validations ####Chain The implementation will be in a chain, where you'll show what the next validation for that element. ####SimpleValidatorException This is the exception that is thrown when one validation to fail and the exception are enabled.
SimpleValidatorException::getInvalidParameterName()
Return what validation failure
####Validations list
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 URL
##Implemeting ####Enabled exception
use 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(); }
####Disabled exception
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 }