Download the PHP package ayeo/validator without Composer
On this page you can find all versions of the php package ayeo/validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ayeo/validator
More information about ayeo/validator
Files in ayeo/validator
Package validator
Short Description Universal and independent validator
License MIT
Homepage https://github.com/ayeo/validator
Informations about the package validator
Validator
Independent library allows to simple validation other objects
Install
Using composer
Example objects
Let's consider simplified objects as below
Validation rules
To process validation we need to define our rules
It is not too sophisticated but works just fine. As you can see we are able to validate nested objects. Validator is smart enough to get private and protected properties (if we got getter). Validator usage:
Default values
Version 1.2 introduced default values support. In order to set default value you need to pass it as third argument. Default value will be used only if field value is null. Be aware that default value as still subject of further validation - if you set invalid default value it will result with error
Allow null
By default given validator will skip checking in case of null value. Of course you need some of them to check even null value. If constraint class implements CheckNull interface validator will force check field even if it is null. At the moment only NotNull constraint it one of this kind.
Availaible constraints
- Length
- MinLength
- MaxLength
- Integer
- Numeric
- NumericMin
- NumericMax
- NotNull
- NonEmpty
- ArrayOfType
- IsArray
- ClassInstance
- NotClassInstance
- LowerThanField
- NoWhitespace
Feel free to add some more!