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

[BUG] Regex failing for e.164 phone number format #225

Open
timfenton-dermi opened this issue Dec 21, 2023 · 1 comment
Open

[BUG] Regex failing for e.164 phone number format #225

timfenton-dermi opened this issue Dec 21, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@timfenton-dermi
Copy link

timfenton-dermi commented Dec 21, 2023

Describe the bug
Attempting to use custom validator for validating a phone number is in e.164 format

phoneNumber            String? /// @zod.custom.use(z.string().regex(/^\+[1-9]\d{1,14}$/));

this pattern is breaking the generation of the zod regex check:

 phoneNumber: z.string(.nullable(),

expected output:

 z.string().regex(/^\+[1-9]\d{1,14}$/)).nullable()

Package versions (please complete the following information):

  • zod: pinned to 3.21.1
  • prisma: 5.7.1

seems to be related to the escaped characters + and \d

@chrishoermann
Copy link
Owner

@timfenton-dermi Thanks for pointing this out. I'll look into it

@chrishoermann chrishoermann added bug Something isn't working and removed bug (unconfirmed) Could be a bug labels Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

2 participants