2015-01-30 09:40:06 +01:00
|
|
|
# Alpha
|
|
|
|
|
2017-03-27 14:47:07 +02:00
|
|
|
- `Alpha()`
|
2018-09-24 21:48:41 +02:00
|
|
|
- `Alpha(string ...$additionalChars)`
|
2015-01-30 09:40:06 +01:00
|
|
|
|
Do not accept whitespace by default in "Alpha" rule
The intent of the "Alpha" rule is to validate alphabetic values.
However, it also considers any whitespace character (by default). That
causes some confusion, and unless you check its code or tests, you would
never expect that behavior.
Because of that confusion, I decided to make "Alpha" to not consider
whitespace characters as valid, and since in the constructor of this
rule it's possible to add extra characters to the validation it makes
sense to let the user decide whether they want whitespaces, tabs, new
lines, etc. or not.
This rule, as the same as "Alnum" previously, extends
"AbstractCtypeRule" pretty much to only make it easier to consider any
whitespaces as valid, therefore I saw no reason to keep extending it.
Now "Alpha" extends the "AbstractFilterRule" which is the parent of
"AbstractCtypeRule".
I also took the opportunity to apply our contribution guidelines to
"Alpha" since we want to apply that to all the rules.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-03 23:18:10 +02:00
|
|
|
Validates whether the input contains only alphabetic characters. This is similar
|
|
|
|
to [Alnum](Alnum.md), but it does not allow numbers.
|
|
|
|
|
|
|
|
```php
|
|
|
|
v::alpha()->validate('some name'); // false
|
|
|
|
v::alpha(' ')->validate('some name'); // true
|
|
|
|
v::alpha()->validate('Cedric-Fabian'); // false
|
|
|
|
v::alpha('-')->validate('Cedric-Fabian'); // true
|
2018-09-24 21:48:41 +02:00
|
|
|
v::alpha('-', '\'')->validate('\'s-Gravenhage'); // true
|
Do not accept whitespace by default in "Alpha" rule
The intent of the "Alpha" rule is to validate alphabetic values.
However, it also considers any whitespace character (by default). That
causes some confusion, and unless you check its code or tests, you would
never expect that behavior.
Because of that confusion, I decided to make "Alpha" to not consider
whitespace characters as valid, and since in the constructor of this
rule it's possible to add extra characters to the validation it makes
sense to let the user decide whether they want whitespaces, tabs, new
lines, etc. or not.
This rule, as the same as "Alnum" previously, extends
"AbstractCtypeRule" pretty much to only make it easier to consider any
whitespaces as valid, therefore I saw no reason to keep extending it.
Now "Alpha" extends the "AbstractFilterRule" which is the parent of
"AbstractCtypeRule".
I also took the opportunity to apply our contribution guidelines to
"Alpha" since we want to apply that to all the rules.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-03 23:18:10 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
You can restrict case using the [Lowercase](Lowercase.md) and
|
|
|
|
[Uppercase](Uppercase.md) rules.
|
|
|
|
|
|
|
|
```php
|
|
|
|
v::alpha()->uppercase()->validate('example'); // false
|
|
|
|
```
|
2015-01-30 09:40:06 +01:00
|
|
|
|
2019-05-11 18:32:13 +02:00
|
|
|
## Categorization
|
|
|
|
|
|
|
|
- Strings
|
|
|
|
|
2017-03-27 22:04:13 +02:00
|
|
|
## Changelog
|
|
|
|
|
|
|
|
Version | Description
|
|
|
|
--------|-------------
|
Do not accept whitespace by default in "Alpha" rule
The intent of the "Alpha" rule is to validate alphabetic values.
However, it also considers any whitespace character (by default). That
causes some confusion, and unless you check its code or tests, you would
never expect that behavior.
Because of that confusion, I decided to make "Alpha" to not consider
whitespace characters as valid, and since in the constructor of this
rule it's possible to add extra characters to the validation it makes
sense to let the user decide whether they want whitespaces, tabs, new
lines, etc. or not.
This rule, as the same as "Alnum" previously, extends
"AbstractCtypeRule" pretty much to only make it easier to consider any
whitespaces as valid, therefore I saw no reason to keep extending it.
Now "Alpha" extends the "AbstractFilterRule" which is the parent of
"AbstractCtypeRule".
I also took the opportunity to apply our contribution guidelines to
"Alpha" since we want to apply that to all the rules.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-09-03 23:18:10 +02:00
|
|
|
2.0.0 | Removed support to whitespaces by default
|
2017-03-27 22:04:13 +02:00
|
|
|
0.3.9 | Created
|
|
|
|
|
2015-08-20 06:38:41 +02:00
|
|
|
***
|
2015-01-30 09:40:06 +01:00
|
|
|
See also:
|
|
|
|
|
2017-03-28 11:53:14 +02:00
|
|
|
- [Alnum](Alnum.md)
|
2018-12-11 13:31:50 +01:00
|
|
|
- [Charset](Charset.md)
|
2017-03-28 11:53:14 +02:00
|
|
|
- [Consonant](Consonant.md)
|
2020-10-05 12:49:14 +02:00
|
|
|
- [Decimal](Decimal.md)
|
2018-12-11 13:31:50 +01:00
|
|
|
- [Digit](Digit.md)
|
|
|
|
- [Lowercase](Lowercase.md)
|
|
|
|
- [NoWhitespace](NoWhitespace.md)
|
2019-01-27 01:14:47 +01:00
|
|
|
- [NotEmoji](NotEmoji.md)
|
2018-12-11 13:31:50 +01:00
|
|
|
- [Regex](Regex.md)
|
|
|
|
- [Uppercase](Uppercase.md)
|
2017-03-28 11:53:14 +02:00
|
|
|
- [Vowel](Vowel.md)
|