[Feature Request] Built-in Phone Validation
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)")
Related https://github.com/colinhacks/zod/issues/3378
Duplicate of #3378, please close
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: https://github.com/colinhacks/zod/pull/3476 as a merged PR back in May.
This issue is for adding @phone (or similar) in zenstack to use this functionality.