respect-validation/docs/rules/Alnum.md
Henrique Moody c99f3818b7
Use variadics "AbstractFilterRule" rule
Since the library doesn't need to give support to version 5.4 or less of
PHP using variadics in the constructor of "AbstractFilterRule" seems
better than doing the whole validation.

This commit will also apply the contribution guidelines to
"AbstractFilterRule" and use a better naming for it.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-10-15 09:41:01 +02:00

945 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
v::alnum('%', ',')->validate('10,5%'); // 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: