respect-validation/docs/validators/Alpha.md
Alexandre Gomes Gaigalas 2a7f345e32 Streamline validators.md index
Makes it so the index looks more like a cheatsheet, condensing
information instead of making long lists that require lots of
scrolling to explore.

Additionally, the happy path for each validator was also
added, providing a quick reference use for comparison.

The direct markdown links were replaced by titled markdown
references, offering mouse-over tooltips over links that
display the validator one-line description.

To ensure a proper source of truth for these new index
goodies, the AssertionMessageLinter was modified to
verify that the first assertion in each doc is a
single-line validator that passes (a happy path), further
making our documentation conventions more solid.
2026-01-28 12:47:08 +00:00

85 lines
2.4 KiB
Markdown

<!--
SPDX-FileCopyrightText: (c) Respect Project Contributors
SPDX-License-Identifier: MIT
-->
# Alpha
- `Alpha()`
- `Alpha(string ...$additionalChars)`
Validates whether the input contains only alphabetic characters. This is similar
to [Alnum](Alnum.md), but it does not allow numbers.
```php
v::alpha(' ')->assert('some name');
// Validation passes successfully
v::alpha()->assert('some name');
// → "some name" must contain only letters (a-z)
v::alpha()->assert('Cedric-Fabian');
// → "Cedric-Fabian" must contain only letters (a-z)
v::alpha('-')->assert('Cedric-Fabian');
// Validation passes successfully
v::alpha('-', '\'')->assert('\'s-Gravenhage');
// Validation passes successfully
```
You can restrict case using the [Lowercase](Lowercase.md) and
[Uppercase](Uppercase.md) validators.
```php
v::alpha()->uppercase()->assert('example');
// → "example" must contain only uppercase letters
```
## Templates
### `Alpha::TEMPLATE_STANDARD`
| Mode | Template |
| ---------: | :------------------------------------------ |
| `default` | {{subject}} must contain only letters (a-z) |
| `inverted` | {{subject}} must not contain letters (a-z) |
### `Alpha::TEMPLATE_EXTRA`
| Mode | Template |
| ---------: | :------------------------------------------------------------------ |
| `default` | {{subject}} must contain only letters (a-z) and {{additionalChars}} |
| `inverted` | {{subject}} must not contain letters (a-z) or {{additionalChars}} |
## Template placeholders
| Placeholder | Description |
| ----------------- | ---------------------------------------------------------------- |
| `additionalChars` | Additional characters that are considered valid. |
| `subject` | The validated input or the custom validator name (if specified). |
## Categorization
- Strings
## Changelog
| Version | Description |
| ------: | :---------------------------------------- |
| 2.0.0 | Removed support to whitespaces by default |
| 0.3.9 | Created |
## See Also
- [Alnum](Alnum.md)
- [Charset](Charset.md)
- [Consonant](Consonant.md)
- [Decimal](Decimal.md)
- [Digit](Digit.md)
- [Emoji](Emoji.md)
- [Lowercase](Lowercase.md)
- [Regex](Regex.md)
- [Spaced](Spaced.md)
- [Uppercase](Uppercase.md)
- [Vowel](Vowel.md)