I am new to using zod for valiadtion. I have read through the documentation but I can see anything on how to add a validation for a phone number.
I used the email one to make sure a user enters a correct email, but how do I do the same for a phone number.
Currently it looks like this:
contactNumber: z
.string()
.min(10, { message: 'Must be a valid mobile number' })
.max(14, { message: 'Must be a valid mobile number' }),
I am just not sure this is correct. I have made it a string because I want the user to be able to put a + in front of the number if necessary for example: +27823456787. I don't want the user to be able to put any letters in the number example: 072r536e98, If the user puts letters I want an error message to say "Must be a valid number".
Can anyone maybe advise me on the correct why to do the validation?