Add "Categorization" section to rule documentations

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2019-05-11 18:32:13 +02:00
parent b815fdff92
commit 10df3211f5
No known key found for this signature in database
GPG key ID: 221E9281655813A6
149 changed files with 657 additions and 9 deletions

View file

@ -8,6 +8,11 @@ Will validate if all inner validators validates.
v::allOf(v::intVal(), v::positive())->validate(15); // true
```
## Categorization
- Composite
- Nesting
## Changelog
Version | Description

View file

@ -26,6 +26,10 @@ v::alnum()->uppercase()->validate('example'); // false
Message template for this validator includes `{{additionalChars}}` as the string
of extra chars passed as the parameter.
## Categorization
- Strings
## Changelog
Version | Description

View file

@ -21,6 +21,10 @@ You can restrict case using the [Lowercase](Lowercase.md) and
v::alpha()->uppercase()->validate('example'); // false
```
## Categorization
- Strings
## Changelog
Version | Description

View file

@ -8,6 +8,10 @@ Validates any input as invalid.
v::alwaysInvalid()->validate('whatever'); // false
```
## Categorization
- Booleans
## Changelog
Version | Description

View file

@ -8,6 +8,10 @@ Validates any input as valid.
v::alwaysValid()->validate('whatever'); // true
```
## Categorization
- Booleans
## Changelog
Version | Description

View file

@ -13,6 +13,11 @@ so `AnyOf()` returns true.
`AnyOf()` returns true if at least one inner validator passes.
## Categorization
- Composite
- Nesting
## Changelog
Version | Description

View file

@ -10,6 +10,11 @@ v::arrayType()->validate([1, 2, 3]); // true
v::arrayType()->validate(new ArrayObject()); // false
```
## Categorization
- Arrays
- Types
## Changelog
Version | Description

View file

@ -11,6 +11,11 @@ v::arrayVal()->validate(new ArrayObject); // true
v::arrayVal()->validate(new SimpleXMLElement('<xml></xml>')); // true
```
## Categorization
- Arrays
- Types
## Changelog
Version | Description

View file

@ -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.
## Categorization
- Nesting
- Objects
- Structures
## Changelog
Version | Description

View file

@ -12,6 +12,10 @@ v::base(16)->validate('012a34f5675c20d'); // true
v::base(2)->validate('0120122001'); // false
```
## Categorization
- Numbers
## Changelog
Version | Description

View file

@ -9,6 +9,10 @@ v::base64()->validate('cmVzcGVjdCE='); // true
v::base64()->validate('respect!'); // false
```
## Categorization
- Strings
## Changelog
Version | Description

View file

@ -10,11 +10,15 @@ v::intVal()->between(10, 20)->validate(15); // true
v::intVal()->between(10, 20)->validate(20); // true
```
Validation makes comparison easier, check out our supported
Validation makes comparison easier, check out our supported
[comparable values](../comparable-values.md).
Message template for this validator includes `{{minValue}}` and `{{maxValue}}`.
## Categorization
- Comparisons
## Changelog
Version | Description

View file

@ -9,6 +9,11 @@ v::boolType()->validate(true); // true
v::boolType()->validate(false); // true
```
## Categorization
- Booleans
- Types
## Changelog
Version | Description

View file

@ -13,6 +13,11 @@ v::boolVal()->validate(1); // true
v::boolVal()->validate(0); // true
```
## Categorization
- Booleans
- Types
## Changelog
Version | Description

View file

@ -8,6 +8,10 @@ Validates a Dutch citizen service number ([BSN](https://nl.wikipedia.org/wiki/Bu
v::bsn()->validate('612890053'); // true
```
## Categorization
- Identifications
## Changelog
Version | Description

View file

@ -40,6 +40,11 @@ v::call(
)->validate($url);
```
## Categorization
- Callables
- Nesting
## Changelog
Version | Description
@ -51,3 +56,4 @@ See also:
- [Callback](Callback.md)
- [Each](Each.md)
- [Sorted](Sorted.md)

View file

@ -10,6 +10,11 @@ v::callableType()->validate('trim'); // true
v::callableType()->validate([new DateTime(), 'format']); // true
```
## Categorization
- Callables
- Types
## Changelog
Version | Description

View file

@ -12,6 +12,10 @@ v::callback(
)->validate(10); // true
```
## Categorization
- Callables
## Changelog
Version | Description

View file

@ -12,6 +12,10 @@ v::charset('ISO-8859-1', 'EUC-JP')->validate('日本国'); // true
The array format is a logic OR, not AND.
## Categorization
- Strings
## Changelog
Version | Description

View file

@ -8,6 +8,10 @@ Validates a Brazilian driver's license.
v::cnh()->validate('02650306461'); // true
```
## Categorization
- Identifications
## Changelog
Version | Description

View file

@ -5,6 +5,10 @@
Validates if the input is a Brazilian National Registry of Legal Entities (CNPJ) number.
Ignores non-digit chars, so use `->digit()` if needed.
## Categorization
- Identifications
## Changelog
Version | Description

View file

@ -10,6 +10,10 @@ characters.
v::cntrl()->validate("\n\r\t"); // true
```
## Categorization
- Strings
## Changelog
Version | Description

View file

@ -9,6 +9,10 @@ Validates if the input contains only consonants.
v::consonant()->validate('xkcd'); // true
```
## Categorization
- Strings
## Changelog
Version | Description

View file

@ -22,6 +22,11 @@ of equal comparison.
Message template for this validator includes `{{containsValue}}`.
## Categorization
- Arrays
- Strings
## Changelog
Version | Description

View file

@ -22,6 +22,11 @@ of equal comparison for arrays.
Message template for this validator includes `{{needles}}`.
## Categorization
- Arrays
- Strings
## Changelog
Version | Description

View file

@ -11,6 +11,10 @@ v::countable()->validate(new ArrayObject()); // true
v::countable()->validate('string'); // false
```
## Categorization
- Types
## Changelog
Version | Description

View file

@ -21,6 +21,11 @@ This rule supports the three sets of country codes:
When no set is defined the rule uses `'alpha-2'` (`CountryCode::ALPHA2`).
## Categorization
- ISO codes
- Localization
## Changelog
Version | Description

View file

@ -21,6 +21,10 @@ the chain:
v::digit()->cpf()->validate('11598647644'); // true
```
## Categorization
- Identifications
## Changelog
Version | Description

View file

@ -34,6 +34,10 @@ It ignores any non-numeric characters, use [Digit](Digit.md),
v::digit()->creditCard()->validate('5376747397208720'); // true
```
## Categorization
- Banking
## Changelog
Version | Description

View file

@ -8,6 +8,11 @@ Validates an [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code lik
v::currencyCode()->validate('GBP'); // true
```
## Categorization
- ISO codes
- Localization
## Changelog
Version | Description

View file

@ -19,7 +19,7 @@ Format | Description
`y` | A two digit representation of a year | Examples: 88 or 17
When a `$format` is not given its default value is `Y-m-d`.
When a `$format` is not given its default value is `Y-m-d`.
```php
v::date()->validate('2017-12-31'); // true
@ -30,6 +30,10 @@ v::date('F jS, Y')->validate('May 1st, 2017'); // true
v::date('Ydm')->validate(20173112); // true
```
## Categorization
- Date and Time
## Changelog
Version | Description

View file

@ -33,6 +33,10 @@ Format has no effect when validating DateTime instances.
Message template for this validator includes `{{format}}`.
## Categorization
- Date and Time
## Changelog
Version | Description

View file

@ -12,6 +12,11 @@ v::digit()->validate('172.655.537-21'); // false
v::digit('.', '-')->validate('172.655.537-21'); // true
```
## Categorization
- Numbers
- Strings
## Changelog
Version | Description

View file

@ -16,6 +16,10 @@ v::directory()->validate(new SplFileInfo('library/'));
v::directory()->validate(dir('/'));
```
## Categorization
- File system
## Changelog
Version | Description

View file

@ -29,6 +29,10 @@ internally:
Messages for this validator will reflect rules above.
## Categorization
- Internet
## Changelog
Version | Description

View file

@ -31,6 +31,11 @@ v::each(v::dateTime())->validate([]); // true
v::notEmpty()->each(v::dateTime())->validate([]); // false
```
## Categorization
- Arrays
- Nesting
## Changelog
Version | Description

View file

@ -8,6 +8,10 @@ Validates an email address.
v::email()->validate('alexandre@gaigalas.net'); // true
```
## Categorization
- Internet
## Changelog
Version | Description

View file

@ -23,6 +23,11 @@ of equal comparison.
Message template for this validator includes `{{endValue}}`.
## Categorization
- Arrays
- Strings
## Changelog
Version | Description

View file

@ -10,6 +10,10 @@ v::equals('alganet')->validate('alganet'); // true
Message template for this validator includes `{{compareTo}}`.
## Categorization
- Comparisons
## Changelog
Version | Description

View file

@ -15,6 +15,10 @@ comparisons.
Message template for this validator includes `{{compareTo}}`.
## Categorization
- Comparisons
## Changelog
Version | Description

View file

@ -10,6 +10,10 @@ v::intVal()->even()->validate(2); // true
Using `int()` before `even()` is a best practice.
## Categorization
- Numbers
## Changelog
Version | Description

View file

@ -8,6 +8,10 @@ Validates if a file is an executable.
v::executable()->validate('script.sh'); // true
```
## Categorization
- File system
## Changelog
Version | Description

View file

@ -15,6 +15,10 @@ This validator will consider SplFileInfo instances, so you can do something like
v::exists()->validate(new SplFileInfo('file.txt'));
```
## Categorization
- File system
## Changelog
Version | Description

View file

@ -10,6 +10,10 @@ v::extension('png')->validate('image.png'); // true
This rule is case-sensitive.
## Categorization
- File system
## Changelog
Version | Description

View file

@ -10,6 +10,11 @@ v::factor(4)->validate(2); // true
v::factor(4)->validate(3); // false
```
## Categorization
- Math
- Numbers
## Changelog
Version | Description

View file

@ -15,6 +15,10 @@ v::falseVal()->validate('0.5'); // false
v::falseVal()->validate('2'); // false
```
## Categorization
- Booleans
## Changelog
Version | Description

View file

@ -10,6 +10,11 @@ v::fibonacci()->validate('34'); // true
v::fibonacci()->validate(6); // false
```
## Categorization
- Math
- Numbers
## Changelog
Version | Description

View file

@ -15,6 +15,10 @@ This validator will consider SplFileInfo instances, so you can do something like
v::file()->validate(new SplFileInfo('file.txt'));
```
## Categorization
- File system
## Changelog
Version | Description

View file

@ -12,6 +12,10 @@ 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
```
## Categorization
- Miscellaneous
## Changelog
Version | Description

View file

@ -9,6 +9,11 @@ v::finite()->validate('10'); // true
v::finite()->validate(10); // true
```
## Categorization
- Math
- Numbers
## Changelog
Version | Description

View file

@ -10,6 +10,11 @@ v::floatType()->validate('1.5'); // false
v::floatType()->validate(0e5); // true
```
## Categorization
- Numbers
- Types
## Changelog
Version | Description

View file

@ -9,6 +9,11 @@ v::floatVal()->validate(1.5); // true
v::floatVal()->validate('1e5'); // true
```
## Categorization
- Numbers
- Types
## Changelog
Version | Description

View file

@ -10,6 +10,10 @@ visible output (no white space).
v::graph()->validate('LKM@#$%4;'); // true
```
## Categorization
- Strings
## Changelog
Version | Description

View file

@ -9,11 +9,15 @@ v::greaterThan(10)->validate(11); // true
v::greaterThan(10)->validate(9); // false
```
Validation makes comparison easier, check out our supported
Validation makes comparison easier, check out our supported
[comparable values](../comparable-values.md).
Message template for this validator includes `{{compareTo}}`.
## Categorization
- Comparisons
## Changelog
Version | Description

View file

@ -10,6 +10,10 @@ v::hexRgbColor()->validate('123123'); // true
v::hexRgbColor()->validate('FCD'); // true
```
## Categorization
- Strings
## Changelog
Version | Description

View file

@ -14,6 +14,10 @@ v::iban()->validate(123456789); // false
v::iban()->validate(''); // false
```
## Categorization
- Banking
## Changelog
Version | Description

View file

@ -11,6 +11,10 @@ v::identical(42)->validate('42'); // false
Message template for this validator includes `{{compareTo}}`.
## Categorization
- Comparisons
## Changelog
Version | Description

View file

@ -13,6 +13,10 @@ v::identityCard('PL')->validate('AYW036731'); // false
For now this rule only accepts Polish Identity Card numbers (Dowód Osobisty).
## Categorization
- Identifications
## Changelog
Version | Description

View file

@ -16,6 +16,10 @@ or of the MIME doesn't match with the file extension.
This rule relies on [fileinfo](http://php.net/fileinfo) PHP extension.
## Categorization
- File system
## Changelog
Version | Description

View file

@ -9,6 +9,10 @@ v::imei()->validate('35-209900-176148-1'); // true
v::imei()->validate('490154203237518'); // true
```
## Categorization
- Identifications
## Changelog
Version | Description

View file

@ -22,6 +22,12 @@ of equal comparison.
Message template for this validator includes `{{haystack}}`.
## Categorization
- Arrays
- Comparisons
- Strings
## Changelog
Version | Description

View file

@ -8,6 +8,11 @@ Validates if the input is an infinite number.
v::infinite()->validate(INF); // true
```
## Categorization
- Math
- Numbers
## Changelog
Version | Description

View file

@ -11,6 +11,10 @@ v::instance('Traversable')->validate(new ArrayObject); // true
Message template for this validator includes `{{instanceName}}`.
## Categorization
- Objects
## Changelog
Version | Description

View file

@ -9,6 +9,11 @@ v::intType()->validate(42); // true
v::intType()->validate('10'); // false
```
## Categorization
- Numbers
- Types
## Changelog
Version | Description

View file

@ -9,6 +9,11 @@ v::intVal()->validate('10'); // true
v::intVal()->validate(10); // true
```
## Categorization
- Numbers
- Types
## Changelog
Version | Description

View file

@ -26,6 +26,10 @@ If you want to validate IPv6 you can do as follow:
v::ip('*', FILTER_FLAG_IPV6)->validate('2001:0db8:85a3:08d3:1319:8a2e:0370:7334'); // true
```
## Categorization
- Internet
## Changelog
Version | Description

View file

@ -11,6 +11,10 @@ v::isbn()->validate('ISBN-12: 978-0-596-52068-7'); // false
v::isbn()->validate('978 10 596 52068 7'); // false
```
## Categorization
- Identifications
## Changelog
Version | Description

View file

@ -13,6 +13,10 @@ v::iterableType()->validate(new stdClass()); // true
v::iterableType()->validate('string'); // false
```
## Categorization
- Types
## Changelog
Version | Description

View file

@ -8,6 +8,10 @@ Validates if the given input is a valid JSON.
v::json()->validate('{"foo":"bar"}'); // true
```
## Categorization
- Strings
## Changelog
Version | Description

View file

@ -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.
## Categorization
- Arrays
- Nesting
- Structures
## Changelog
Version | Description

View file

@ -30,6 +30,12 @@ v::keyNested('foo.bar')->validate($object); // true
This rule was inspired by [Yii2 ArrayHelper][].
## Categorization
- Arrays
- Nesting
- Structures
## Changelog
Version | Description

View file

@ -45,6 +45,12 @@ v::keySet(
The keys' order is not considered in the validation.
## Categorization
- Arrays
- Nesting
- Structures
## Changelog
Version | Description

View file

@ -57,6 +57,11 @@ The above code may generate the message:
password_confirmation must equal "password"
```
## Categorization
- Arrays
- Nesting
## Changelog
Version | Description

View file

@ -15,6 +15,11 @@ v::languageCode('alpha-3')->validate('eng'); // true
You can choose between `alpha-2` and `alpha-3`; `alpha-2` is set by default set.
## Categorization
- ISO codes
- Localization
## Changelog
Version | Description

View file

@ -11,6 +11,10 @@ v::leapDate('Y-m-d')->validate('1988-02-29'); // true
This validator accepts DateTime instances as well. The $format
parameter is mandatory.
## Categorization
- Date and Time
## Changelog
Version | Description

View file

@ -10,6 +10,10 @@ v::leapYear()->validate('1988'); // true
This validator accepts DateTime instances as well.
## Categorization
- Date and Time
## Changelog
Version | Description

View file

@ -9,11 +9,15 @@ v::lessThan(10)->validate(9); // true
v::lessThan(10)->validate(10); // false
```
Validation makes comparison easier, check out our supported
Validation makes comparison easier, check out our supported
[comparable values](../comparable-values.md).
Message template for this validator includes `{{compareTo}}`.
## Categorization
- Comparisons
## Changelog
Version | Description

View file

@ -8,6 +8,10 @@ Validates whether the characters in the input are lowercase.
v::stringType()->lowercase()->validate('xkcd'); // true
```
## Categorization
- Strings
## Changelog
Version | Description

View file

@ -9,13 +9,16 @@ v::luhn()->validate('2222400041240011'); // true
v::luhn()->validate('respect!'); // false
```
## Categorization
- Identifications
## Changelog
Version | Description
--------|-------------
2.0.0 | Created
[Luhn]: https://en.wikipedia.org/wiki/Luhn_algorithm
***
See also:

View file

@ -9,6 +9,10 @@ v::macAddress()->validate('00:11:22:33:44:55'); // true
v::macAddress()->validate('af-AA-22-33-44-55'); // true
```
## Categorization
- Identifications
## Changelog
Version | Description

View file

@ -10,11 +10,15 @@ v::max(10)->validate(10); // true
v::max(10)->validate(11); // false
```
Validation makes comparison easier, check out our supported
Validation makes comparison easier, check out our supported
[comparable values](../comparable-values.md).
Message template for this validator includes `{{compareTo}}`.
## Categorization
- Comparisons
## Changelog
Version | Description

View file

@ -18,6 +18,10 @@ v::maxAge(18, 'Y-m-d')->validate('1988-09-09'); // false
Using [Date](Date.md) before is a best-practice.
This rule does not accepts instances of [DateTimeInterface][].
## Categorization
- Date and Time
## Changelog
Version | Description

View file

@ -11,6 +11,10 @@ v::mimetype('image/jpeg')->validate('image.jpg'); // true
This rule is case-sensitive and requires [fileinfo](http://php.net/fileinfo) PHP extension.
## Categorization
- File system
## Changelog
Version | Description

View file

@ -10,11 +10,15 @@ v::intVal()->min(10)->validate(10); // true
v::intVal()->min(10)->validate(11); // true
```
Validation makes comparison easier, check out our supported
Validation makes comparison easier, check out our supported
[comparable values](../comparable-values.md).
Message template for this validator includes `{{compareTo}}`.
## Categorization
- Comparisons
## Changelog
Version | Description

View file

@ -18,6 +18,10 @@ v::minAge(18, 'Y-m-d')->validate('2010-09-07'); // false
Using [Date](Date.md) before is a best-practice.
This rule does not accepts instances of [DateTimeInterface][].
## Categorization
- Date and Time
## Changelog
Version | Description

View file

@ -8,6 +8,11 @@ Validates if the input is a multiple of the given parameter
v::intVal()->multiple(3)->validate(9); // true
```
## Categorization
- Math
- Numbers
## Changelog
Version | Description

View file

@ -8,6 +8,11 @@ Validates whether the input is a negative number.
v::numericVal()->negative()->validate(-15); // true
```
## Categorization
- Math
- Numbers
## Changelog
Version | Description

View file

@ -8,6 +8,10 @@ Validates the access key of the Brazilian electronic invoice (NFe).
v::nfeAccessKey()->validate('31841136830118868211870485416765268625116906'); // true
```
## Categorization
- Identifications
## Changelog
Version | Description

View file

@ -9,6 +9,10 @@ v::nif()->validate('49294492H'); // true
v::nif()->validate('P6437358A'); // false
```
## Categorization
- Identifications
## Changelog
Version | Description

View file

@ -38,6 +38,10 @@ setlocale(LC_ALL, 'es_ES');
v::no(true)->validate('Yes'); // true
```
## Categorization
- Booleans
## Changelog
Version | Description

View file

@ -11,6 +11,10 @@ v::noWhitespace()->validate("foo\nbar"); // false
This is most useful when chaining with other validators such as `Alnum()`
## Categorization
- Strings
## Changelog
Version | Description

View file

@ -13,6 +13,11 @@ v::noneOf(
In the sample above, 'foo' isn't a integer nor a float, so noneOf returns true.
## Categorization
- Composite
- Nesting
## Changelog
Version | Description

View file

@ -18,6 +18,11 @@ v::not(v::intVal()->positive())->validate(-1.5); // true
Each other validation has custom messages for negated rules.
## Categorization
- Conditions
- Nesting
## Changelog
Version | Description

View file

@ -26,6 +26,10 @@ v::notBlank()->validate(new stdClass()); // false
It's similar to [NotEmpty](NotEmpty.md) but it's way more strict.
## Categorization
- Miscellaneous
## Changelog
Version | Description

View file

@ -22,6 +22,10 @@ first emoji or until it checks the whole text.
Unicode V11 check the following link for more details
[Unicode v11](https://unicode.org/emoji/charts/full-emoji-list.html)*
## Categorization
- Strings
## Changelog
Version | Description

View file

@ -35,6 +35,10 @@ v::stringType()->notEmpty()->validate(' '); //false
v::stringType()->notEmpty()->validate("\t \n \r"); //false
```
## Categorization
- Miscellaneous
## Changelog
Version | Description

View file

@ -29,6 +29,10 @@ v::notOptional()->validate([[''), [0]]); // true
v::notOptional()->validate(new stdClass()); // true
```
## Categorization
- Miscellaneous
## Changelog
Version | Description

View file

@ -8,6 +8,10 @@ Validates whether the input is [null](http://php.net/types.null).
v::nullType()->validate(null); // true
```
## Categorization
- Types
## Changelog
Version | Description

View file

@ -10,6 +10,10 @@ v::nullable(v::email())->validate('example@example.com'); // true
v::nullable(v::email())->validate('not an email'); // false
```
## Categorization
- Nesting
## Changelog
Version | Description

View file

@ -13,6 +13,10 @@ v::number()->validate(acos(8)); // false
> representing an undefined or unrepresentable value, especially in
> floating-point calculations." [Wikipedia](https://en.wikipedia.org/wiki/NaN)
## Categorization
- Numbers
## Changelog
Version | Description

Some files were not shown because too many files have changed in this diff Show more