( value: string | null | undefined, expectedPrefix: 'app' | 'tbl' | 'ach', paramName = 'ID' )
| 842 | * ``` |
| 843 | */ |
| 844 | export function validateAirtableId( |
| 845 | value: string | null | undefined, |
| 846 | expectedPrefix: 'app' | 'tbl' | 'ach', |
| 847 | paramName = 'ID' |
| 848 | ): ValidationResult { |
| 849 | if (value === null || value === undefined || value === '') { |
| 850 | return { |
| 851 | isValid: false, |
| 852 | error: `${paramName} is required`, |
| 853 | } |
| 854 | } |
| 855 | |
| 856 | const airtableIdPattern = new RegExp(`^${expectedPrefix}[a-zA-Z0-9]{14}$`) |
| 857 | |
| 858 | if (!airtableIdPattern.test(value)) { |
| 859 | logger.warn('Invalid Airtable ID format', { |
| 860 | paramName, |
| 861 | expectedPrefix, |
| 862 | value: value.substring(0, 20), |
| 863 | }) |
| 864 | return { |
| 865 | isValid: false, |
| 866 | error: `${paramName} must be a valid Airtable ID starting with "${expectedPrefix}"`, |
| 867 | } |
| 868 | } |
| 869 | |
| 870 | return { isValid: true, sanitized: value } |
| 871 | } |
| 872 | |
| 873 | /** |
| 874 | * Validates an AWS region identifier |
no test coverage detected