mirror of
https://github.com/Respect/Validation.git
synced 2026-03-17 15:50:03 +01:00
The "Alnum" rule is supposed to validate alphanumeric values, but instead, it also validates any whitespace character as valid. The rule also accepts a list of characters on its constructor, so it the users intentionally want some specific characters to also be allowed it is better than they also defined these characters on the rule's constructor. While refactoring the rule I could notice that "AbstractCtypeRule" is just an overhead that does not add much to it, so instead of extending it "Alnum" now extends "AbstractFilterRule" directly (which is the parent of "AbstractCtypeRule"). And since we want all rules to follow our contribution guidelines, this commit also make sure the "Alnum" rule is in accordance with that. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
895 B
895 B
Alnum
Alnum()Alnum(string $additionalChars)
Validates whether the input is alphanumeric or not.
Alphanumeric is a combination of alphabetic (a-z and A-Z) and numeric (0-9) characters.
v::alnum()->validate('foo 123'); // false
v::alnum(' ')->validate('foo 123'); // true
v::alnum()->validate('100%'); // false
v::alnum('%')->validate('100%'); // true
You can restrict case using the Lowercase and Uppercase rules.
v::alnum()->uppercase()->validate('example'); // false
Message template for this validator includes {{additionalChars}} as the string
of extra chars passed as the parameter.
Changelog
| Version | Description |
|---|---|
| 2.0.0 | Removed support to whitespaces by default |
| 0.3.9 | Created |
See also: