Skip to main content

programming-parse-incoming-data-instead-of-only-validating-it

#post

programming-parse-incoming-data-instead-of-only-validating-it

A function that only validates will output a boolean (or nothing if “didn’t raise an error” is your function’s approach to indicating validity). In contrast, a function that parses outputs your type or null. In the process of parsing into your type, you validate as well. The benefit is you get to capture the information provided by your validation logic in your new type.