←back to thread

Parse, don't validate (2019)

(lexi-lambda.github.io)
398 points declanhaigh | 1 comments | | HN request time: 0.217s | source
1. arminsergiony ◴[] No.35054835[source]
I believe that JSON Schema is a great solution because it is a standardized format and provides helpful error messages for validation issues. If the schema file is well-defined, it should be safe to map the JSON data to a static type DTO and trust that the data types are valid. JSON Schema's ability to validate strings, numbers, integers, and custom objects makes it a powerful tool, and I personally wouldn't want to attempt to implement something similar on my own.