Validations
Validations is a static utility class providing reusable input validation methods. All methods delegate to StaticRegexPatterns from the constants layer, ensuring regex definitions are centralized and consistent.
API
| Method | Signature | Rule |
|---|---|---|
validateEmail |
(email: string) → boolean |
Matches a standard email pattern via StaticRegexPatterns.email. |
validatePassword |
(password: string) → boolean |
Matches the platform password policy via StaticRegexPatterns.password. |
validateUrl |
(url: string) → boolean |
Matches well-formed URLs via StaticRegexPatterns.url. |
validatePhoneNumber |
(phoneNumber: string) → boolean |
Strips all non-digit characters (except +), then matches via StaticRegexPatterns.phoneNumber. |
Data Flow

::: info Phone Number Normalization
validatePhoneNumber is the only method that normalizes input before testing. It strips all characters except digits and +, allowing users to enter phone numbers in formats like (555) 123-4567 or +1-555-123-4567.
:::
Usage
import { Validations } from '@/lib/internal/Validations';
Validations.validateEmail('user@example.com'); // true
Validations.validatePassword('Str0ng!Pass'); // true / false depending on policy
Validations.validateUrl('https://example.com'); // true
Validations.validatePhoneNumber('+1 (555) 123-4567'); // true (normalized to +15551234567)
Design Decisions
- Static class, no instantiation — validation is stateless and context-free.
- Centralized patterns — regex definitions live in
StaticRegexPatterns, not in the validation class. This prevents pattern duplication. - Boolean return — methods return
true/falseonly. Error messaging is the caller's responsibility.