Design Patterns · Senior · Question 57 of 75
What does "parse, don't validate" mean?
- ✓Correct answer: Turn untrusted input into a more precise type once at the boundary, so the rest of the code can't receive invalid data
- 2Never validate user input
- 3Use
JSON.parseinstead of schemas
Explanation
A validator returning boolean loses information; a parser returning Email or an error keeps the proof in the type.