| ▲ | dhussoe an hour ago | ||||||||||||||||
"parse don't validate" is from: https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-va... looking at zod (assuming https://zod.dev) it is a parsing library by that definition — which isn't, like, an official definition or anything, one person on the internet came up with it, but I think it is good at getting the principle across under these definitions a "parser" takes some input and returns either some valid output (generally a more specific type, like String -> URL) or an error, whereas a "validator" just takes that input and returns a boolean or throws an error or whatever makes sense in the language. eta: probably part of the distinction here is that since zod is a JS library the actual implementation can be a "validator" and then the original parsed JSON input can just be returned with a different type. "parse don't validate" is (IMO) more popular in languages like Rust where you would already need to parse the JSON to a language-native structure from the original bytes, or to some "JSON" type like https://docs.rs/serde_json/latest/serde_json/enum.Value.html that are generally awkward for application code (nudging you onto the happy parsing path). | |||||||||||||||||
| ▲ | koakuma-chan 42 minutes ago | parent [-] | ||||||||||||||||
I like your message and I think that you are right on everything. | |||||||||||||||||
| |||||||||||||||||