Alphabets class provides a set of predefined character strings that can be used with validation rules like shouldOnlyContain, notContain, and mustContainOne. These constants make it easy to validate that input contains only specific types of characters.
Import
Available Alphabets
Numeric Systems
BIN
Binary digits (base-2)OCT
Octal digits (base-8)HEX
Hexadecimal digits (base-16)English Alphabets
NUMBER
Numeric digits (0-9)ALPHABET
English letters (mixed case)ALPHA_LOWERCASE
Lowercase English lettersALPHA_UPPERCASE
Uppercase English lettersALPHA_NUMERIC
English letters and numbersSpanish Alphabets
These alphabets include Spanish-specific characters like ñ, á, é, í, ó, ú.ALPHABET_ES
Spanish letters (mixed case) with accentsALPHA_LOWERCASE_ES
Lowercase Spanish letters with accentsALPHA_UPPERCASE_ES
Uppercase Spanish letters with accentsALPHA_NUMERIC_ES
Spanish letters (with accents) and numbersUsage with Validation Rules
Alphabets are most commonly used with these validation rules:shouldOnlyContain
Validate that input contains only characters from the alphabet:notContain
Validate that input does not contain any characters from the alphabet:mustContainOne
Validate that input contains at least one character from the alphabet:mustContainMin
Validate that input contains a minimum number of characters from the alphabet:Custom Alphabets
You can also create your own custom alphabets for specific validation needs:Use Cases
Password Validation
Username Validation
Color Hex Code Validation
Spanish Name Validation
Related
- Validators - Static validation methods
- Regular Expressions - Predefined regex patterns
- String Rules - String validation rules
- Validator - Main validation class