Course lesson
Apply Schema Custom Refinement with Zod
In this lesson, we dive into the Zod's refine utility, allowing defining more complex schema validation on top of existing schemas and utilities.
- Duration
- 6 min
- Access
- Included
- Transcript
- Needs source
In this lesson, we dive into the Zod's refine utility, allowing defining more complex schema validation on top of existing schemas and utilities.
Sometimes, we need special validation rules for our applications to work correctly. The refine utility lets developers create their own validation rules. This method's uses a callback to check if the input is valid. We also create meaningful messages when something doesn’t meet the validation rules.
We use a practical example involving a room booking schemawith dueDate and price property refinement.