“Why validate JSON responses via Zod if the app just crashes if the schema...
“Why validate JSON responses via Zod if the app just crashes if the schema validation fails?”
Good question.
True, there’s typically no good workaround for receiving malformed JSON.
Here’s the value of Zod:
1. I know precisely where the app crashed and why. Zod fails fast and loud (which is easier to debug than failing slowly or quietly)
2. Typically the schema validation fails during development. This sure beats being surprised by unexpected JSON in production!