respect-validation/docs/Alnum.md
2015-08-20 01:38:41 -03:00

975 B

Alnum

  • v::alnum()
  • v::alnum(string $additionalChars)

Validates alphanumeric characters from a-Z and 0-9.

v::alnum()->validate('foo 123'); //true

A parameter for extra characters can be used:

v::alnum('-')->validate('foo - 123'); //true

This validator allows whitespace, if you want to remove them add ->noWhitespace() to the chain:

v::alnum()->noWhitespace->validate('foo 123'); //false

By default empty values are allowed, if you want to invalidate them, add ->notEmpty() to the chain:

v::alnum()->notEmpty()->validate(''); //false

You can restrict case using the ->lowercase() and ->uppercase() validators:

v::alnum()->uppercase()->validate('aaa'); //false

Message template for this validator includes {{additionalChars}} as the string of extra chars passed as the parameter.


See also: