Download the PHP package solbianca/validator without Composer
On this page you can find all versions of the php package solbianca/validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download solbianca/validator
More information about solbianca/validator
Files in solbianca/validator
Package validator
Short Description Easy to use, highly customisable PHP validator.
License MIT
Homepage https://github.com/solbianca/validator
Informations about the package validator
PHP Validator
This is an easy to use and customisable PHP validator.
Note: This package is under development and not recommended for production.
Installing
Install via composer
`
or add to composer.json
Basic usage
Adding custom rules
Adding custom rules is simple. It can be any callable or object which implement SolBianca\Validator\Interfaces\RuleInterface
If the callable returns false, the rule fails.
Rewrite rules
Validator have useful default rules as int
, required
and many more. You can rewrite any rule by your own.
Adding custom error messages
You can add custom error messages for any rule
Adding rule messages in bulk
Using Field Aliases
Field Aliases helps you format any error messages without showing weird form names or the need to create a custom error.
Rules
Array
If the value is an array.
``
Between
Checks if the value is within the intervals defined. This check is inclusive, so 5 is between 5 and 10.
``
Bool
If the value is a boolean.
``
If the value is a valid email.
``
Int
If the value is an integer, including numbers within strings. 1 and '1' are both classed as integers.
``
Ip
If the value is a valid IP address.
``
Matches
Checks if one given input matches the other. For example, checking if password matches password_confirm.
``
Max
Check if string length is less than or equal to given int. To check the size of a number, pass the optional number option.
``
Mix
Check if string length is greater than or equal to given int. To check the size of a number, pass the optional number option.
``
Number
If the value is a number, including numbers within strings.
Numeric strings consist of optional sign, any number of digits, optional decimal part and optional exponential part. Thus +0123.45e6 is a valid numeric value. Hexadecimal (e.g. 0xf4c3b00c), Binary (e.g. 0b10100111001), Octal (e.g. 0777) notation is allowed too but only without sign, decimal and exponential part.
``
Regex
If the given input has a match for the regular expression given.
``
Required
If the value is present.
``
Url
If the value is formatted as a valid URL.
``