MCPcopy Index your code
hub / github.com/simstudioai/sim / validateAirtableId

Function validateAirtableId

apps/sim/lib/core/security/input-validation.ts:844–871  ·  view source on GitHub ↗
(
  value: string | null | undefined,
  expectedPrefix: 'app' | 'tbl' | 'ach',
  paramName = 'ID'
)

Source from the content-addressed store, hash-verified

842 * ```
843 */
844export 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

Callers 4

createSubscriptionFunction · 0.90
deleteSubscriptionFunction · 0.90
route.tsFile · 0.90

Calls 2

testMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected