Download the PHP package igniphp/validation without Composer
On this page you can find all versions of the php package igniphp/validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package validation
Igni Validation
Licensed under MIT License.
Igni validation is simple, lightweight and extensible validation library.
Installation
Introduction
Basic example
Getting error information
Allows to validate complex arrays
API
Validation list
- alnum
- alpha
- boolean
- chain
- contains
- date
- each
- falsy
- group
- in
- integer
- ip
- ipv4
- ipv6
- number
- regex
- text
- truthy
- uri
- url
- uuid
Assertion::alnum(int $min = null, int $max = null)
Creates validator that checks if passed value contains only digits and letters.
Parameters
$min
defines minimum length$max
defines maximum length
Example
Assertion::alpha(int $min = null, int $max = null)
Creates validator that checks if passed value contains only letters.
Parameters
$min
defines minimum length$max
defines maximum length
Example
Assertion::boolean()
Creates validator that checks if passed value is valid boolean expression.
Example
Assertion::chain(Rule ...$rules)
Creates validator that uses other validators to perform multiple validations on passed value.
Example
Assertion::contains(string $value)
Creates validator that checks if passed string is contained in the validated string.
Example
Assertion::date(string $format = null, $min = null, $max = null)
Creates validator that checks if passed value is valid date.
Parameters
$format
restricts format of passed value$min
defines minimum date range$max
defines maximum date range
Example
Assertion::email()
Creates validator that checks if passed value is valid email address.
Example
Assertion::each(Validator $validator)
Creates validator that checks if each item in passed set can be successfully validated against $validator
.
Parameters
$validator
validator used for each item of the passed set.
Example
Assertion::falsy()
Creates validator that checks if passed value is valid falsy expression;
off
no
false
- 0
Example
Assertion::group(array $validatorsHash)
Creates validator with key/value hash that validates other hashes.
Example
Assertion::regex(string $pattern)
Creates validator that checks if passed string matches the pattern.
Example
Assertion::truthy()
Creates validator that checks if passed value is valid truthy expression;
on
true
- 1
yes
Example
Assertion::text(int $minLength = null, int $maxLength = null)
Creates validator that checks if passed value is string.
Parameters
$minLength
defines minimum length$maxLength
defines maximum length
Example
Assertion::in(...$values)
Creates validator that checks if passed value exists in defined list of values.
Example
Assertion::integer(int $min = null, int $max = null)
Creates validator that checks if passed value is valid integer expression.
Parameters
$min
defines minimum value$max
defines maximum value
Example
Assertion::ip()
Creates validator that checks if passed value is valid ip address.
Example
Assertion::ipv4()
Creates validator that checks if passed value is valid ip v4 address.
Example
Assertion::ipv6()
Creates validator that checks if passed value is valid ip v6 address.
Example
Assertion::number(int $min = null, int $max = null)
Creates validator that checks if passed value is valid number expression.
Parameters
$min
defines minimum value$max
defines maximum value
Example
Assertion::uuid()
Creates validator that checks if passed value is valid uuid.
Example
Assertion::uri()
Creates validator that checks if passed value is valid uri string.
Example
Assertion::url()
Creates validator that checks if passed value is valid url string.
Example
Assertion::text()
Creates validator that accepts every non empty string.
Assertion::group(array $validators)
Creates validator that validates passed value by group of defined validators.
Example
Creating custom validator
To create custom validator we have to simply extend \Igni\Validation\Assertion
class, please consider following example:
That's all folks!