Complex Schema Validation
So far our form validator is able to check for values.
Form has name, email, and optionally will have phoneNumber and website.
However, we want to put some constraints on what the values can be.
The user shouldn't be able to pass an invalid URLs, phone numbers, or website urls.
Your challenge is to find Zod APIs for adding validation to our Form types.
Phone numbers should have the right amount of characters. Email addresses and URLs should look right.
You'll know it works when the tests all pass!
Matt Pocock: Here we're back to another form file data, except this one is a little bit more complex because we've got this name, phoneNumber, email, website. All of these things we're validating.
What we want to do is we want to say you can't pass an invalid URL to the website. You can't pass an invalid email to this email, either. You can't pass an invalid phone number to here.
For phone number, we're just using you can't pass a phone number if it's got too few characters and you can't pass a phone number with too many characters. We are saying if it's not a good email, then you can't pass it. If it doesn't look like an email there. You should throw when you pass an invalid website URL.
This is not a valid website URL. We need a http://facebook.com or whatever. Your challenge is to go into the Zod API and see if you can find some kind of neat little ways to do this validation because Zod does provide them.