2 ms·
I thought the idea of parse, don't validate is that your parser should contain validation logic. So instead of text -> generic json parser -> validate json ->
by dnautics 5y ago
I thought the idea of parse, don't validate is that your parser should contain validation logic.
So instead of
text -> generic json parser -> validate json -> ...
you would do
text -> custom json parser that stops if encounters "incorrect content" -> ...
- yakshaving_jgt 5y agoYou can think of the parser as containing validation logic — it can parse the value into a more constrained type if it conforms to validation rules, or it can fail. The point is that once your value is in a more principled type, the rest of the system is free from having to make assumptions (and guard against potential failures) about the breadth of that value's domain. As the article mentions, this is really only relevant to languages with proper type systems like Haskell.