Download the PHP package fresh-advance/array-validator without Composer
On this page you can find all versions of the php package fresh-advance/array-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download fresh-advance/array-validator
More information about fresh-advance/array-validator
Files in fresh-advance/array-validator
Download fresh-advance/array-validator
More information about fresh-advance/array-validator
Files in fresh-advance/array-validator
Vendor fresh-advance
Package array-validator
Short Description The component validates form data or any given array by provided rule list.
License MIT
Package array-validator
Short Description The component validates form data or any given array by provided rule list.
License MIT
Please rate this library. Is it a good library?
Informations about the package array-validator
Array Validator
Simple form data / any array validation tool.
- Component validates an array by provided rules list.
- Its possible to use multiple configurations of one rule for one field in one validation run.
- Not dependant on other third party components.
- Tested with PHP 7.3 and up, including PHP 8.0. Fits PSR-12 coding style.
Installation
Installation via composer:
Usage example
Gives validation errors with fields as keys:
Predefined Rules
There are some basic rules implemented with the component:
-
Callback(closure $closure)
- Takes Closure as parameter. $key and $data will be sent to Closure.
-
EqualsTo(mixed $value)
- Check if value is equal to Rule $value parameter.
-
EqualsToKey(string $key)
- Check if value is equal to other key value.
-
Expression(string $regex)
- Takes regex as parameter.
-
Filter(int $filterRule, array $filterOptions)
- Rule uses
filter_var
function for validating the value. - Takes PHP filter constants to apply as first param:
- FILTER_VALIDATE_EMAIL
- FILTER_VALIDATE_FLOAT
- FILTER_VALIDATE_INT
- FILTER_VALIDATE_IP
- FILTER_VALIDATE_MAC
- FILTER_VALIDATE_REGEXP
- FILTER_VALIDATE_URL
- Takes
filter_var
options array as second param. - Refer to
filter_var
function documentation for more information
- Rule uses
-
InArray(array $choices)
- Length(int $length)
-
LengthRange(int $min, int $max)
- Max(int $max)
-
MaxLength(int $max)
- Min(int $min)
-
MinLength(int $min)
- Range(int $min, int $max)
- Required
- Check if the field exists and not empty
Create and use custom Rules
- Custom rule should extend
\Sieg\ArrayValidator\Rule\AbstractRule
- Use it as regular rules whose comes with the component.
- Validator catches
\Sieg\ArrayValidator\Exception\RuleFailed
type Exceptions for setting field error messages.
All versions of array-validator with dependencies
PHP Build Version
Package Version
Requires
php Version
>=7.3
The package fresh-advance/array-validator contains the following files
Loading the files please wait ....