Skip to content

Commit

Permalink
Fix phone validation
Browse files Browse the repository at this point in the history
  • Loading branch information
parkerdavis1 committed Dec 28, 2023
1 parent 347faad commit 1900d80
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/utils/user-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ export const emailSchema = z

export const phoneSchema = z
.string()
.regex(/\(?\d{3}\)?\s?-?\d{3}-?\d{4}/, { message: 'Phone number must be ten digits'})
.transform(phone => phone.replaceAll(/\D/g, ''))
.regex(/^\(?\d{3}\)?\s?-?\d{3}-?\d{4}$/, {
message: 'Phone number must be ten digits',
})
.transform(phone => phone.replaceAll(/\D/g, ''))

0 comments on commit 1900d80

Please sign in to comment.