Home / Function/ getPhoneProviderValidationSchema() — supabase Function Reference

getPhoneProviderValidationSchema() — supabase Function Reference

Architecture documentation for the getPhoneProviderValidationSchema() function in AuthProvidersFormValidation.tsx from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  cea6c08c_3446_b168_effe_644c8d16d4af["getPhoneProviderValidationSchema()"]
  683c3026_918c_b840_cac9_92aa5efe44ea["AuthProvidersForm()"]
  683c3026_918c_b840_cac9_92aa5efe44ea -->|calls| cea6c08c_3446_b168_effe_644c8d16d4af
  19a08a5e_820f_d79a_6470_0733446026f5["smsProviderValidation()"]
  cea6c08c_3446_b168_effe_644c8d16d4af -->|calls| 19a08a5e_820f_d79a_6470_0733446026f5
  style cea6c08c_3446_b168_effe_644c8d16d4af fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/Auth/AuthProvidersFormValidation.tsx lines 115–217

export const getPhoneProviderValidationSchema = (config: ProjectAuthConfigData) => {
  return object().shape({
    EXTERNAL_PHONE_ENABLED: boolean().required(),
    SMS_PROVIDER: string(),

    // Twilio
    SMS_TWILIO_ACCOUNT_SID: string().when(['EXTERNAL_PHONE_ENABLED', 'SMS_PROVIDER'], {
      ...smsProviderValidation(config, 'twilio'),
      then: (schema) => schema.required('Twilio Account SID is required'),
      otherwise: (schema) => schema,
    }),
    SMS_TWILIO_AUTH_TOKEN: string().when(['EXTERNAL_PHONE_ENABLED', 'SMS_PROVIDER'], {
      ...smsProviderValidation(config, 'twilio'),
      then: (schema) => schema.required('Twilio Auth Token is required'),
      otherwise: (schema) => schema,
    }),
    SMS_TWILIO_MESSAGE_SERVICE_SID: string().when(['EXTERNAL_PHONE_ENABLED', 'SMS_PROVIDER'], {
      ...smsProviderValidation(config, 'twilio'),
      then: (schema) => schema.required('Twilio Message Service SID is required'),
      otherwise: (schema) => schema,
    }),

    // Twilio Verify
    SMS_TWILIO_VERIFY_ACCOUNT_SID: string().when(['EXTERNAL_PHONE_ENABLED', 'SMS_PROVIDER'], {
      ...smsProviderValidation(config, 'twilio_verify'),
      then: (schema) => schema.required('Twilio Verify Account SID is required'),
      otherwise: (schema) => schema,
    }),
    SMS_TWILIO_VERIFY_AUTH_TOKEN: string().when(['EXTERNAL_PHONE_ENABLED', 'SMS_PROVIDER'], {
      ...smsProviderValidation(config, 'twilio_verify'),
      then: (schema) => schema.required('Twilio Verify Auth Token is required'),
      otherwise: (schema) => schema,
    }),
    SMS_TWILIO_VERIFY_MESSAGE_SERVICE_SID: string().when(
      ['EXTERNAL_PHONE_ENABLED', 'SMS_PROVIDER'],
      {
        ...smsProviderValidation(config, 'twilio_verify'),
        then: (schema) => schema.required('Twilio Verify Service SID is required'),
        otherwise: (schema) => schema,
      }
    ),

    // Messagebird
    SMS_MESSAGEBIRD_ACCESS_KEY: string().when(['EXTERNAL_PHONE_ENABLED', 'SMS_PROVIDER'], {
      ...smsProviderValidation(config, 'messagebird'),
      then: (schema) => schema.required('Messagebird Access Key is required'),
      otherwise: (schema) => schema,
    }),
    SMS_MESSAGEBIRD_ORIGINATOR: string().when(['EXTERNAL_PHONE_ENABLED', 'SMS_PROVIDER'], {
      ...smsProviderValidation(config, 'messagebird'),
      then: (schema) => schema.required('Messagebird Originator is required'),
      otherwise: (schema) => schema,
    }),

    // Textlocal
    SMS_TEXTLOCAL_API_KEY: string().when(['EXTERNAL_PHONE_ENABLED', 'SMS_PROVIDER'], {
      ...smsProviderValidation(config, 'textlocal'),
      then: (schema) => schema.required('Textlocal API Key is required'),
      otherwise: (schema) => schema,
    }),
    SMS_TEXTLOCAL_SENDER: string().when(['EXTERNAL_PHONE_ENABLED', 'SMS_PROVIDER'], {
      ...smsProviderValidation(config, 'textlocal'),
      then: (schema) => schema.required('Textlocal Sender is required'),
      otherwise: (schema) => schema,
    }),

    // Vonage
    SMS_VONAGE_API_KEY: string().when(['EXTERNAL_PHONE_ENABLED', 'SMS_PROVIDER'], {
      ...smsProviderValidation(config, 'vonage'),
      then: (schema) => schema.required('Vonage API is required'),
      otherwise: (schema) => schema,
    }),
    SMS_VONAGE_API_SECRET: string().when(['EXTERNAL_PHONE_ENABLED', 'SMS_PROVIDER'], {
      ...smsProviderValidation(config, 'vonage'),
      then: (schema) => schema.required('Vonage API Secret is required'),
      otherwise: (schema) => schema,
    }),
    SMS_VONAGE_FROM: string().when(['EXTERNAL_PHONE_ENABLED', 'SMS_PROVIDER'], {
      ...smsProviderValidation(config, 'vonage'),
      then: (schema) => schema.required('Vonage From is required'),
      otherwise: (schema) => schema,
    }),

    // Phone SMS
    SMS_OTP_EXP: number().min(0, 'Must be more than 0').required('This is required'),
    SMS_OTP_LENGTH: number().min(6, 'Must be 6 or more in length').required('This is required'),
    SMS_TEMPLATE: string().required('SMS template is required.'),
    SMS_TEST_OTP: string()
      .matches(
        /^\s*([0-9]{1,15}=[0-9]+)(\s*,\s*[0-9]{1,15}=[0-9]+)*\s*$/g,
        'Must be a comma-separated list of <phone number>=<OTP> pairs. Phone numbers should be in international format, without spaces, dashes or the + prefix. Example: 123456789=987654'
      )
      .trim()
      .transform((value: string) => value.replace(/\s+/g, '')),
    SMS_TEST_OTP_VALID_UNTIL: string().when(['SMS_TEST_OTP'], {
      is: (SMS_TEST_OTP: string | null) => {
        return !!SMS_TEST_OTP
      },
      then: (schema) => schema.required('You must provide a valid until date.'),
      otherwise: (schema) => schema.transform((value: string) => ''),
    }),
  })
}

Subdomains

Frequently Asked Questions

What does getPhoneProviderValidationSchema() do?
getPhoneProviderValidationSchema() is a function in the supabase codebase.
What does getPhoneProviderValidationSchema() call?
getPhoneProviderValidationSchema() calls 1 function(s): smsProviderValidation.
What calls getPhoneProviderValidationSchema()?
getPhoneProviderValidationSchema() is called by 1 function(s): AuthProvidersForm.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free