mirror of
https://github.com/Respect/Validation.git
synced 2024-06-04 14:52:17 +02:00
Add changelog to rules' documentation
Also: - Create documentation for `Base` rule; - Increase number of rules
This commit is contained in:
parent
569506bc14
commit
00d300f762
|
@ -11,7 +11,7 @@
|
|||
|
||||
- Complex rules made simple: `v::numericVal()->positive()->between(1, 255)->validate($input)`.
|
||||
- [Granularity control](docs/README.md#validation-methods) for advanced reporting.
|
||||
- More than 100 (fully tested) validators.
|
||||
- [More than 130](docs/VALIDATORS.md) (fully tested) validation rules.
|
||||
- [A concrete API](docs/CONCRETE_API.md) for non fluent usage.
|
||||
- Works on PHP 7.0 or above
|
||||
|
||||
|
|
|
@ -37,6 +37,12 @@ v::age(null, 70)->validate('71 years ago'); // false
|
|||
|
||||
Message template for this validator includes `{{minAge}}` and `{{maxAge}}`.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.9.0 | Created based on deprecated `MinimumAge` rule
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -11,16 +11,11 @@ v::allOf(
|
|||
)->validate(15); // true
|
||||
```
|
||||
|
||||
This is similar to the chain (which is an allOf already), but
|
||||
its syntax allows you to set custom names for every node:
|
||||
## Changelog
|
||||
|
||||
```php
|
||||
v::allOf(
|
||||
v::intVal()->setName('Account Number'),
|
||||
v::positive()->setName('Higher Than Zero')
|
||||
)->setName('Positive integer')
|
||||
->validate(15); // true
|
||||
```
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
|
|
@ -32,6 +32,12 @@ v::alnum()->uppercase()->validate('aaa'); // false
|
|||
Message template for this validator includes `{{additionalChars}}` as
|
||||
the string of extra chars passed as the parameter.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
|
||||
This is similar to `Alnum()`, but it doesn't allow numbers.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -8,6 +8,12 @@ Always return false.
|
|||
v::alwaysInvalid()->validate($whatever); // false
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.5.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -8,6 +8,12 @@ Always returns true.
|
|||
v::alwaysValid()->validate($whatever); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.5.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -16,6 +16,13 @@ so `AnyOf()` returns true.
|
|||
|
||||
`AnyOf()` returns true if at least one inner validator passes.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
2.0.0 | Renamed from `OneOf` to `AnyOf`
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -10,6 +10,12 @@ v::arrayType()->validate([1, 2, 3]); // true
|
|||
v::arrayType()->validate(new ArrayObject()); // false
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -11,6 +11,16 @@ v::arrayVal()->validate(new ArrayObject); // true
|
|||
v::arrayVal()->validate(new SimpleXMLElement($xml)); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
2.0.0 | `SimpleXMLElement` is also considered as valid
|
||||
1.0.0 | Renamed from `Arr` to `ArrayVal` and validate only if the input can be used as an array (#1)
|
||||
0.3.9 | Created as `Arr`
|
||||
|
||||
1. Previously this rule considered `Traversable` and `Countable` as valid inputs.
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -27,6 +27,12 @@ v::attribute('lorem', v::stringType(), false)->validate($obj); // true
|
|||
|
||||
The name of this validator is automatically set to the attribute name.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -13,6 +13,12 @@ These country codes are supported:
|
|||
|
||||
* "de" (Germany): Respect\Validation supports version >=1.1.0 of "malkusch/bav" for this rule.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.8.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -13,6 +13,12 @@ These country codes are supported:
|
|||
|
||||
* "de" (Germany): Respect\Validation supports version >=1.1.0 of "malkusch/bav" for this rule.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.8.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
25
docs/Base.md
Normal file
25
docs/Base.md
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Base
|
||||
|
||||
- `Base(string $base)`
|
||||
|
||||
Validate numbers in any base, even with non regular bases.
|
||||
|
||||
```php
|
||||
v::base(2)->validate('011010001'); // true
|
||||
v::base(3)->validate('0120122001'); // true
|
||||
v::base(8)->validate('01234567520'); // true
|
||||
v::base(16)->validate('012a34f5675c20d'); // true
|
||||
v::base(2)->validate('0120122001'); // false
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.5.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
* [BaseAccount](BaseAccount.md)
|
||||
* [Bic](Bic.md)
|
|
@ -36,6 +36,13 @@ v::date()->between(10, 20, true)->validate(20); // true
|
|||
|
||||
Message template for this validator includes `{{minValue}}` and `{{maxValue}}`.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Became inclusive by default
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -13,6 +13,12 @@ Theses country codes are supported:
|
|||
|
||||
* "de" (Germany): Respect\Validation supports version >=1.1.0 of "malkusch/bav" for this rule.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.8.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -9,6 +9,13 @@ v::boolType()->validate(true); // true
|
|||
v::boolType()->validate(false); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Renamed from `Bool` to `BoolType`
|
||||
0.3.9 | Created as `Bool`
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -13,6 +13,12 @@ v::boolVal()->validate(1); // true
|
|||
v::boolVal()->validate(0); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -8,6 +8,12 @@ Validates a Dutch citizen service number ([BSN](https://nl.wikipedia.org/wiki/Bu
|
|||
v::bsn()->validate('612890053'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
10
docs/Call.md
10
docs/Call.md
|
@ -1,6 +1,6 @@
|
|||
# Call
|
||||
|
||||
- `Call(callable $callback)`
|
||||
- `Call(callable $callable, Rule $rule)`
|
||||
|
||||
This is a very low level validator. It calls a function, method or closure
|
||||
for the input and then validates it. Consider the following variable:
|
||||
|
@ -26,7 +26,7 @@ v::arrayVal()->key('scheme', v::startsWith('http'))
|
|||
->key('query', v::notEmpty());
|
||||
```
|
||||
|
||||
Using `Call()` you can do this in a single chain:
|
||||
Using `v::call()` you can do this in a single chain:
|
||||
|
||||
```php
|
||||
v::call(
|
||||
|
@ -45,6 +45,12 @@ v::call([$myObj, 'methodName'], v::intVal())->validate($myInput);
|
|||
v::call(function($input) {}, v::intVal())->validate($myInput);
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -10,6 +10,12 @@ v::callableType()->validate('trim'); // true
|
|||
v::callableType()->validate([new ObjectType, 'methodName']); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -13,6 +13,12 @@ v::callback('is_int')->validate(10); // true
|
|||
|
||||
As in `Call()`, you can pass a method or closure to it.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -12,6 +12,12 @@ v::charset(['ISO-8859-1', 'EUC-JP'])->validate('日本国'); // true
|
|||
|
||||
The array format is a logic OR, not AND.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.5.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -8,6 +8,12 @@ Validates a Brazillian driver's license.
|
|||
v::cnh()->validate('02650306461'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.5.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
Validates the Brazillian CNPJ number. Ignores non-digit chars, so
|
||||
use `->digit()` if needed.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -9,6 +9,12 @@ This is similar to `Alnum()`, but only accepts control characters:
|
|||
v::cntrl()->validate("\n\r\t"); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.5.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -9,6 +9,13 @@ Similar to `Alnum()`. Validates strings that contain only consonants:
|
|||
v::consonant()->validate('xkcd'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.5.0 | Renamed from `Consonants` to `Consonant`
|
||||
0.3.9 | Created as `Consonants`
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
# Contains
|
||||
|
||||
- `Contains(mixed $value)`
|
||||
- `Contains(mixed $value, bool $identical)`
|
||||
- `Contains(mixed $expectedValue)`
|
||||
- `Contains(mixed $expectedValue, bool $identical)`
|
||||
|
||||
Validates if the input contains some value.
|
||||
|
||||
For strings:
|
||||
|
||||
|
@ -20,6 +22,12 @@ of equal comparison.
|
|||
|
||||
Message template for this validator includes `{{containsValue}}`.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -11,6 +11,12 @@ v::countable()->validate(new ArrayObject()); // true
|
|||
v::countable()->validate('string'); // false
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created from `ArrayVal`
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -8,6 +8,12 @@ Validates an ISO country code like US or BR.
|
|||
v::countryCode()->validate('BR'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.5.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -21,6 +21,12 @@ the chain:
|
|||
v::digit()->cpf()->validate('44455566820'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -31,6 +31,13 @@ It ignores any non-digit chars, so use `->digit()` when appropriate.
|
|||
v::digit()->creditCard()->validate('5376747397208720'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.1.0 | Allow the define credit card brand
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -8,6 +8,12 @@ Validates an [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code lik
|
|||
v::currencyCode()->validate('GBP'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -31,6 +31,12 @@ Format has no effect when validating DateTime instances.
|
|||
|
||||
Message template for this validator includes `{{format}}`.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -4,6 +4,13 @@
|
|||
|
||||
This is similar to `Alnum()`, but it doesn't allow a-Z.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.5.0 | Renamed from `Digits` to `Digit`
|
||||
0.3.9 | Created as `Digits`
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -15,6 +15,12 @@ This validator will consider SplFileInfo instances, so you can do something like
|
|||
v::directory()->validate(new \SplFileInfo($directory));
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.4.4 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -29,6 +29,13 @@ internally:
|
|||
|
||||
Messages for this validator will reflect rules above.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.6.0 | Allow to skip TLD check
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -20,6 +20,12 @@ v::arrayVal()->each(v::date(), v::stringType()->lowercase())->validate($releaseD
|
|||
|
||||
Using `arrayVal()` before `each()` is a best practice.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -8,6 +8,13 @@ Validates an email address.
|
|||
v::email()->validate('alexandre@gaigalas.net'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.9.0 | Use "egulias/emailvalidator" for email validation
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -23,6 +23,12 @@ of equal comparison.
|
|||
|
||||
Message template for this validator includes `{{endValue}}`.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Equals
|
||||
|
||||
- `Equals(mixed $value)`
|
||||
- `Equals(mixed $compareTo)`
|
||||
|
||||
Validates if the input is equal to some value.
|
||||
|
||||
|
@ -10,6 +10,13 @@ v::equals('alganet')->validate('alganet'); // true
|
|||
|
||||
Message template for this validator includes `{{compareTo}}`.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Removed identical checking (see [Identical](Identical.md))
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -10,6 +10,12 @@ v::intVal()->even()->validate(2); // true
|
|||
|
||||
Using `int()` before `even()` is a best practice.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -8,6 +8,12 @@ Validates if a file is an executable.
|
|||
v::email()->executable('script.sh'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.7.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -15,6 +15,12 @@ This validator will consider SplFileInfo instances, so you can do something like
|
|||
v::exists()->validate(new \SplFileInfo($file));
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.5.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -10,6 +10,12 @@ v::extension('png')->validate('image.png'); // true
|
|||
|
||||
This rule is case-sensitive.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -10,6 +10,12 @@ v::factor(4)->validate(2); // true
|
|||
v::factor(4)->validate(3); // false
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -15,6 +15,13 @@ v::falseVal()->validate('0.5'); // false
|
|||
v::falseVal()->validate('2'); // false
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Renamed from `False` to `FalseVal`
|
||||
0.8.0 | Created as `False`
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -10,6 +10,12 @@ v::fibonacci()->validate('34'); // true
|
|||
v::fibonacci()->validate(6); // false
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.1.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -15,6 +15,12 @@ This validator will consider SplFileInfo instances, so you can do something like
|
|||
v::file()->validate(new \SplFileInfo($file));
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.5.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -12,6 +12,12 @@ v::filterVar(FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)->validate('http://e
|
|||
v::filterVar(FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)->validate('http://example.com/path'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.8.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -9,6 +9,12 @@ v::finite()->validate('10'); // true
|
|||
v::finite()->validate(10); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -10,6 +10,12 @@ v::floatType()->validate('1.5'); // false
|
|||
v::floatType()->validate(0e5); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -9,6 +9,12 @@ v::floatVal()->validate(1.5); // true
|
|||
v::floatVal()->validate('1e5'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -9,6 +9,12 @@ Validates all characters that are graphically represented.
|
|||
v::graph()->validate('LKM@#$%4;'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.5.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -10,6 +10,12 @@ v::hexRgbColor()->validate('123123'); // true
|
|||
v::hexRgbColor()->validate('FCD'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.7.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -11,6 +11,12 @@ v::identical(42)->validate('42'); // false
|
|||
|
||||
Message template for this validator includes `{{compareTo}}`.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -13,6 +13,12 @@ v::identityCard('PL')->validate('AYW036731'); // false
|
|||
|
||||
For now this rule only accepts Polish Identity Card numbers (Dowód Osobisty).
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.1.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -16,6 +16,12 @@ or of the MIME doesn't match with the file extension.
|
|||
|
||||
This rule relies on [fileinfo](http://php.net/fileinfo) PHP extension.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.1.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -9,6 +9,12 @@ v::imei()->validate('35-209900-176148-1'); // true
|
|||
v::imei()->validate('490154203237518'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -22,6 +22,12 @@ of equal comparison.
|
|||
|
||||
Message template for this validator includes `{{haystack}}`.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -8,6 +8,12 @@ Validates if the input is an infinite number.
|
|||
v::infinite()->validate(INF); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -11,6 +11,12 @@ v::instance('Traversable')->validate(new ArrayObject); // true
|
|||
|
||||
Message template for this validator includes `{{instanceName}}`.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -9,6 +9,12 @@ v::intType()->validate(42); // true
|
|||
v::intType()->validate('10'); // false
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -9,6 +9,13 @@ v::intVal()->validate('10'); // true
|
|||
v::intVal()->validate(10); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Renamed from `Int` to `IntVal`
|
||||
0.3.9 | Created as `Int`
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -16,6 +16,13 @@ You can pass a parameter with filter_var flags for IP.
|
|||
v::ip(FILTER_FLAG_NO_PRIV_RANGE)->validate('127.0.0.1'); // false
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.5.0 | Implemented IP range validatio
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -12,6 +12,13 @@ v::iterableType()->validate(new stdClass()); // true
|
|||
v::iterableType()->validate('string'); // false
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.8 | Renamed from `Iterable` to `IterableType`
|
||||
1.0.0 | Created as `Iterable`
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -8,6 +8,12 @@ Validates if the given input is a valid JSON.
|
|||
v::json()->validate('{"foo":"bar"}'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
12
docs/Key.md
12
docs/Key.md
|
@ -1,8 +1,8 @@
|
|||
# Key
|
||||
|
||||
- `new Key(string $name)`
|
||||
- `new Key(string $name, Validatable $rule)`
|
||||
- `new Key(string $name, Validatable $rule, bool $mandatory)`
|
||||
- `Key(mixed $key)`
|
||||
- `Key(mixed $key, Validatable $rule)`
|
||||
- `Key(mixed $key, Validatable $rule, bool $mandatory)`
|
||||
|
||||
Validates an array key.
|
||||
|
||||
|
@ -28,6 +28,12 @@ v::key('lorem', v::stringType(), false)->validate($dict); // true
|
|||
|
||||
The name of this validator is automatically set to the key name.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -30,6 +30,12 @@ v::keyNested('foo.bar')->validate($object); // true
|
|||
|
||||
This rule was inspired by [Yii2 ArrayHelper][].
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -45,6 +45,12 @@ v::keySet(
|
|||
|
||||
The keys' order is not considered in the validation.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -53,6 +53,12 @@ The above code may generate the message:
|
|||
password_confirmation must be equals "password"
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -14,7 +14,13 @@ v::languageCode('alpha-3')->validate('eng'); // true
|
|||
|
||||
You can choose between alpha-2 and alpha-3, alpha-2 is set by default.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.1.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
* [CountryCode](CountryCode.md)
|
||||
* [CountryCode](CountryCode.md)
|
||||
|
|
|
@ -11,6 +11,12 @@ v::leapDate('Y-m-d')->validate('1988-02-29'); // true
|
|||
This validator accepts DateTime instances as well. The $format
|
||||
parameter is mandatory.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -10,6 +10,12 @@ v::leapYear()->validate('1988'); // true
|
|||
|
||||
This validator accepts DateTime instances as well.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -38,6 +38,12 @@ v::stringType()->length(1, 5, true)->validate('a'); // true
|
|||
|
||||
Message template for this validator includes `{{minValue}}` and `{{maxValue}}`.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -8,6 +8,12 @@ Validates if string characters are lowercase in the input:
|
|||
v::stringType()->lowercase()->validate('xkcd'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -9,6 +9,12 @@ v::macAddress()->validate('00:11:22:33:44:55'); // true
|
|||
v::macAddress()->validate('af-AA-22-33-44-55'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -29,6 +29,13 @@ values must be used.
|
|||
|
||||
Message template for this validator includes `{{maxValue}}`.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Became inclusive by default
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -10,6 +10,12 @@ v::mimetype('image/png')->validate('image.png'); // true
|
|||
|
||||
This rule is case-sensitive and requires [fileinfo](http://php.net/fileinfo) PHP extension.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -22,6 +22,13 @@ values must be used.
|
|||
|
||||
Message template for this validator includes `{{minValue}}`.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Became inclusive by default
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -16,6 +16,12 @@ Using `date()` before is a best-practice.
|
|||
|
||||
Message template for this validator includes `{{age}}`.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -8,6 +8,12 @@ Validates if the input is a multiple of the given parameter
|
|||
v::intVal()->multiple(3)->validate(9); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -8,6 +8,12 @@ Validates if a number is lower than zero
|
|||
v::numericVal()->negative()->validate(-15); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -8,6 +8,12 @@ Validates the access key of the Brazilian electronic invoice (NFe).
|
|||
v::nfeAccessKey()->validate('31841136830118868211870485416765268625116906'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.6.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -9,6 +9,12 @@ v::nif()->validate('49294492H'); // true
|
|||
v::nif()->validate('P6437358A'); // false
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
2.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -18,6 +18,12 @@ This rule is case insensitive.
|
|||
|
||||
If `$locale` is TRUE, uses the value of [nl_langinfo()](http://php.net/nl_langinfo) with `NOEXPR` constant.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.7.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -11,6 +11,12 @@ v::noWhitespace()->validate("foo\nbar"); // false
|
|||
|
||||
This is most useful when chaining with other validators such as `Alnum()`
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -13,6 +13,12 @@ v::noneOf(
|
|||
|
||||
In the sample above, 'foo' isn't a integer nor a float, so noneOf returns true.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -18,6 +18,12 @@ v::not(v::intVal()->positive())->validate(-1.5); // true
|
|||
|
||||
Each other validation has custom messages for negated rules.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -26,6 +26,12 @@ v::notBlank()->validate(new stdClass()); // false
|
|||
|
||||
It's similar to [NotEmpty](NotEmpty.md) but it's way more strict.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
- `NotEmpty()`
|
||||
|
||||
Validates if the given input is not empty or in other words is input mandatory and
|
||||
required. This function also takes whitespace into account, use `noWhitespace()`
|
||||
if no spaces or linebreaks and other whitespace anywhere in the input is desired.
|
||||
Validates if the given input is not empty. This function also takes whitespace
|
||||
into account, use `noWhitespace()` if no spaces or linebreaks and other
|
||||
whitespace anywhere in the input is desired.
|
||||
|
||||
```php
|
||||
v::stringType()->notEmpty()->validate(''); // false
|
||||
|
@ -35,6 +35,12 @@ v::stringType()->notEmpty()->validate(' '); //false
|
|||
v::stringType()->notEmpty()->validate("\t \n \r"); //false
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -29,6 +29,12 @@ v::notOptional()->validate([[''), [0]]); // true
|
|||
v::notOptional()->validate(new stdClass()); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -8,6 +8,13 @@ Validates if the input is null.
|
|||
v::nullType()->validate(null); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Renamed from `NullValue` to `NullType`
|
||||
0.3.9 | Created as `NullValue`
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -9,6 +9,13 @@ v::numericVal()->validate(-12); // true
|
|||
v::numericVal()->validate('135.0'); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
2.0.0 | Renamed from `Numeric` to `NumericVal`
|
||||
0.3.9 | Created as `Numeric`
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -8,6 +8,13 @@ Validates if the input is an object.
|
|||
v::objectType()->validate(new stdClass); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Renamed from `Object` to `ObjectType`
|
||||
0.3.9 | Created as `Object`
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -10,6 +10,12 @@ v::intVal()->odd()->validate(3); // true
|
|||
|
||||
Using `int()` before `odd()` is a best practice.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -14,6 +14,12 @@ v::oneOf(v::digit(), v::alpha())->validate('*'); // false
|
|||
The chains above validate if the input is either a digit or an alphabetic
|
||||
character, one or the other, but not neither nor both.
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
2.0.0 | Created (see [AnyOf](AnyOf.md))
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -10,6 +10,11 @@ v::optional(v::alpha())->validate(''); // true
|
|||
v::optional(v::digit())->validate(null); // true
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.0.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
|
|
@ -9,6 +9,12 @@ v::perfectSquare()->validate(25); // true (5*5)
|
|||
v::perfectSquare()->validate(9); // true (3*3)
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
0.3.9 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
|
|
|
@ -11,10 +11,16 @@ v::pesel()->validate('97072704801'); // false
|
|||
v::pesel()->validate('PESEL123456'); // false
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
1.1.0 | Created
|
||||
|
||||
***
|
||||
See also:
|
||||
|
||||
* [Bank](Bank.md)
|
||||
* [IdentityCard](IdentityCard.md)
|
||||
* [SubdivisionCode](SubdivisionCode.md)
|
||||
* [Vatin](Vatin.md)
|
||||
* [Vatin](Vatin.md)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue