|
11 | 11 |
|
12 | 12 | from .base import BaseCustomSettings |
13 | 13 |
|
14 | | -# Based on https://countrycode.org/ |
15 | 14 | CountryCodeStr: TypeAlias = Annotated[ |
16 | 15 | str, |
17 | 16 | BeforeValidator(str), |
| 17 | + # Based on https://countrycode.org/ |
18 | 18 | StringConstraints(strip_whitespace=True, pattern=r"^\d{1,4}"), |
19 | 19 | ] |
20 | 20 |
|
21 | 21 |
|
22 | 22 | class TwilioSettings(BaseCustomSettings): |
23 | | - TWILIO_ACCOUNT_SID: str = Field(..., description="Twilio account String Identifier") |
24 | | - TWILIO_AUTH_TOKEN: str = Field(..., description="API tokens") |
25 | | - TWILIO_COUNTRY_CODES_W_ALPHANUMERIC_SID_SUPPORT: list[CountryCodeStr] = Field( |
26 | | - default=TypeAdapter(list[CountryCodeStr]).validate_python( |
27 | | - [ |
28 | | - "41", |
29 | | - ], |
| 23 | + TWILIO_ACCOUNT_SID: Annotated[ |
| 24 | + str, |
| 25 | + Field(description="Twilio account String Identifier"), |
| 26 | + ] |
| 27 | + |
| 28 | + TWILIO_AUTH_TOKEN: Annotated[ |
| 29 | + str, |
| 30 | + Field(description="API tokens"), |
| 31 | + ] |
| 32 | + |
| 33 | + TWILIO_COUNTRY_CODES_W_ALPHANUMERIC_SID_SUPPORT: Annotated[ |
| 34 | + list[CountryCodeStr], |
| 35 | + Field( |
| 36 | + description="list of country-codes supporting/registered for alphanumeric sender ID" |
| 37 | + "See https://support.twilio.com/hc/en-us/articles/223133767-International-support-for-Alphanumeric-Sender-ID", |
30 | 38 | ), |
31 | | - description="list of country-codes supporting/registered for alphanumeric sender ID" |
32 | | - "See https://support.twilio.com/hc/en-us/articles/223133767-International-support-for-Alphanumeric-Sender-ID", |
| 39 | + ] = TypeAdapter(list[CountryCodeStr]).validate_python( |
| 40 | + [ |
| 41 | + "41", |
| 42 | + ], |
33 | 43 | ) |
34 | 44 |
|
35 | 45 | def is_alphanumeric_supported(self, phone_number: str) -> bool: |
|
0 commit comments