| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| export function isValidPhone(phone: string): boolean { |
| if (!phone || typeof phone !== 'string') return false; |
|
|
| const cleaned = phone.replace(/[\s\-()]/g, ''); |
|
|
| |
| const tenDigit = /^[6-9]\d{9}$/; |
| |
| const withCountryCode = /^(\+91|91)[6-9]\d{9}$/; |
|
|
| return tenDigit.test(cleaned) || withCountryCode.test(cleaned); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| export function isValidEmail(email: string): boolean { |
| if (!email || typeof email !== 'string') return false; |
|
|
| |
| const emailRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; |
|
|
| return emailRegex.test(email.trim()); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| export function isValidVehicleNumber(num: string): boolean { |
| if (!num || typeof num !== 'string') return false; |
|
|
| const cleaned = num.replace(/[\s\-]/g, '').toUpperCase(); |
|
|
| |
| const regex = /^[A-Z]{2}[0-9]{1,3}[A-Z]{1,3}[0-9]{1,4}$/; |
|
|
| return regex.test(cleaned); |
| } |
|
|
| |
| |
| |
| export function isNotEmpty(value: string | null | undefined): boolean { |
| return typeof value === 'string' && value.trim().length > 0; |
| } |
|
|
| |
| |
| |
| |
| |
| export function isValidPinCode(pin: string): boolean { |
| if (!pin || typeof pin !== 'string') return false; |
| return /^[1-9][0-9]{5}$/.test(pin.trim()); |
| } |
|
|
| |
| |
| |
| export function isValidDisplayName(name: string): boolean { |
| if (!name || typeof name !== 'string') return false; |
| const trimmed = name.trim(); |
| return trimmed.length >= 2 && trimmed.length <= 50 && /^[a-zA-Z\s.\-']+$/.test(trimmed); |
| } |
|
|