Download the PHP package pklink/validator-chain without Composer
On this page you can find all versions of the php package pklink/validator-chain. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pklink/validator-chain
More information about pklink/validator-chain
Files in pklink/validator-chain
Package validator-chain
Short Description Perform validation in a chain
License MIT
Informations about the package validator-chain
ValidatorChain
A library to perform several validations in a chain.
Installation
Install ValidationChain
with Composer
Create or update your composer.json
And run Composer
Finally include Composers autoloader
Basic Usage
Create an instance of Chain
with the value you like to check
Now, run some tests in a chain
If you want to know if all validations run fine use the isValid
-method
Alternatively you can use this in one statement:
Reset chain
Use reset()
to reset your chain.
Options
You can set different options with instantiation or the setter for the appropriate option.
throwExceptionOnFailure
If this option is set to true
then Chain
will throw a Validator\Exception
if a validation failed.
Default is set to false
The setter for this option is throwExceptionOnFailure()
stopValidationOnFailure
If this option is set to true
then Chain
will not perform any further validation.
Default is set to true
The setter for this option is stopValidationOnFailure()
Listener for failures
You can add Closures to get notifications on failures.
This example will output: failure
If you like you can use the failed \Validator\Rule
in your listener
Rules
hasKey()
hasKeys()
isArray()
isInteger()
isInt()
Alias for isInteger()
isNull()
isNull()
isNumeric()
isObject()
isScalar()
isString()
lengthOf( int $length )
maximumLengthOf( int $length )
minumumLengthOf( int $length )
Add your own rule
Run Tests
You can use PHPUnit from the vendor-folder.
or with code-coverage-report
License
This package is licensed under the MIT License. See the LICENSE file for details.