mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 15:25:45 +01:00
They only know what message a rule produces when they try running it. Including the messages in the documentation will make it easier for people to know what to expect. There are a couple of undocumented placeholders, but I can live with that for now.
1.4 KiB
1.4 KiB
Length
Length(Rule $rule)
Validates the length of the given input against a given rule.
v::length(v::between(1, 5))->isValid('abc'); // true
v::length(v::greaterThan(5))->isValid('abcdef'); // true
v::length(v::lessThan(5))->isValid('abc'); // true
This rule can be used to validate the length of strings, arrays, and objects that implement the Countable interface.
v::length(v::greaterThanOrEqual(3))->isValid([1, 2, 3]); // true
v::length(v::equals(0))->isValid(new SplPriorityQueue()); // true
Templates
Length::TEMPLATE_STANDARD
| Mode | Template |
|---|---|
default |
The length of |
inverted |
The length of |
Template placeholders
| Placeholder | Description |
|---|---|
name |
The validated input or the custom validator name (if specified). |
Categorization
- Comparisons
- Transformations
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Became a transformation |
| 0.3.9 | Created |
See also: