mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 23:35:45 +01:00
The "Digit" rule is meant to validate digits. However, by default, it also considers any whitespace character (spaces, new lines, tabs, etc) as valid. Since the rule also accepts a list of characters to ignore during the validation it seemed logical to me to leave the responsibility of allowing whitespace characters on the hands of the one who uses the rule. The messages of the exception are not really consistent, this commit will also fix that. It's also clear that the "AbstractCtypeRule" is an unnecessary overhead since it is only a proxy for "AbstractFilterRule". That one can and should even be removed after this commit is applied especially because this commit will also remove the method "filterWhiteSpaceOption" which is the only substantial difference between "AbstractCtypeRule" and "AbstractFilterRule". This commit will also apply our guidelines to the "Digit" rule since we want to do that to all the rules we have. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
605 B
605 B
Digit
Digit()Digit(string $additionalChars)
Validates whether the input contains only digits.
v::digit()->validate('020 612 1851'); // false
v::digit(' ')->validate('020 612 1851'); // true
v::digit()->validate('172.655.537-21'); // false
v::digit('.-')->validate('172.655.537-21'); // true
Changelog
| Version | Description |
|---|---|
| 2.0.0 | Removed support to whitespaces by default |
| 0.5.0 | Renamed from Digits to Digit |
| 0.3.9 | Created as Digits |
See also: