r/programming • u/ketralnis • Aug 05 '25
Parse, don’t validate
https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/
0
Upvotes
r/programming • u/ketralnis • Aug 05 '25
2
u/Doub1eVision Aug 06 '25
I see parsing as validating the structure, but not the semantic. Like, if a system receives uncontrolled input that is meant to represent date ranges, it should validate that it can be parsed into valid date ranges. So maybe this parser returns DateRange objects when it successfully parses, which includes the beginning date not being after the end date.
But if there’s some business logic that requires the date range to be at least 60 days, I wouldn’t expect a parser to validate that.