2015-01-30 09:40:06 +01:00
|
|
|
# Alnum
|
|
|
|
|
2017-03-27 14:47:07 +02:00
|
|
|
- `Alnum()`
|
|
|
|
- `Alnum(string $additionalChars)`
|
2015-01-30 09:40:06 +01:00
|
|
|
|
|
|
|
Validates alphanumeric characters from a-Z and 0-9.
|
|
|
|
|
|
|
|
```php
|
2015-10-20 02:53:25 +02:00
|
|
|
v::alnum()->validate('foo 123'); // true
|
2015-01-30 09:40:06 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
A parameter for extra characters can be used:
|
|
|
|
|
|
|
|
```php
|
2015-10-20 02:53:25 +02:00
|
|
|
v::alnum('-')->validate('foo - 123'); // true
|
2015-01-30 09:40:06 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
This validator allows whitespace, if you want to
|
|
|
|
remove them add `->noWhitespace()` to the chain:
|
|
|
|
|
|
|
|
```php
|
2015-10-20 02:53:25 +02:00
|
|
|
v::alnum()->noWhitespace()->validate('foo 123'); // false
|
2015-01-30 09:40:06 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
You can restrict case using the `->lowercase()` and
|
|
|
|
`->uppercase()` validators:
|
|
|
|
|
|
|
|
```php
|
2015-10-20 02:53:25 +02:00
|
|
|
v::alnum()->uppercase()->validate('aaa'); // false
|
2015-01-30 09:40:06 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
Message template for this validator includes `{{additionalChars}}` as
|
|
|
|
the string of extra chars passed as the parameter.
|
|
|
|
|
2017-03-27 22:04:13 +02:00
|
|
|
## Changelog
|
|
|
|
|
|
|
|
Version | Description
|
|
|
|
--------|-------------
|
|
|
|
0.3.9 | Created
|
|
|
|
|
2015-08-20 06:38:41 +02:00
|
|
|
***
|
2015-01-30 09:40:06 +01:00
|
|
|
See also:
|
|
|
|
|
|
|
|
* [Alpha](Alpha.md)
|
|
|
|
* [Digit](Digit.md)
|
|
|
|
* [Consonant](Consonant.md)
|
|
|
|
* [Vowel](Vowel.md)
|