Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Built-in Phone Validation #1897

Open
hongkongkiwi opened this issue Nov 30, 2024 · 3 comments
Open

[Feature Request] Built-in Phone Validation #1897

hongkongkiwi opened this issue Nov 30, 2024 · 3 comments

Comments

@hongkongkiwi
Copy link

hongkongkiwi commented Nov 30, 2024

Please add an additional validation for phone numbers. This is a pretty common need especially with SMS 2FA, I think this is useful to setup so we can have a @phone

E.164 phone number (used for Phone/SMS etc)

/**
 * Validates a string field value is a valid E.164 phone number format (+[country code][number])
 */
attribute @phone(_ message: String?) @@@targetField([StringField]) @@@validation @@@supportTypeDef

I'm currently using it with a regex, but I think it's worth having it built-in:

  /// The phone number in E.164 format (e.g., +16175551212)
  phone String? @regex('^\\+[1-9]\\d{1,14}$', message: "Phone number must be in E.164 format (e.g., +16175551212)")
@ymc9
Copy link
Member

ymc9 commented Dec 2, 2024

Related colinhacks/zod#3378

@MickL
Copy link

MickL commented Dec 4, 2024

Duplicate of #3378, please close

@hongkongkiwi
Copy link
Author

hongkongkiwi commented Dec 5, 2024

Duplicate of #3378, please close

No this is not a duplicate. That is related and links to zod E.164 phone number validation. Which actually seems to have been already added in Zod: colinhacks/zod#3476 as a merged PR back in May.

This issue is for adding @phone (or similar) in zenstack to use this functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants