Open JeelRajodiya opened 8 months ago
I never implemented descriptive error messaging. The theory was that the standard JSON Schema output format, would allow people to write tools to consume that format to give you nice error messaging that makes sense for your specific use case. There are a couple such implementations that use AJV's proprietary output format. There's one designed for CLI consumption and another designed for API responses. Unfortunately, no one ever built things like that for the standard output format, so for now there isn't really something I can point you to solve this problem. I'll have to give up waiting for someone else to do it and do it myself, but I haven't had time yet.
I recently shared with another user some code to get started if you want to see how to build out some messaging yourself.
Thanks a lot! Should I close the issue?
I think you can leave it open. It will help others with the same question find the answer they're looking for. I'll close it in the future if/when the situation changes.
The reason no one (including the AJV maintainer) has written the standard message parser is because it is a humongous task once you realize it is pretty useless without multilang support. And multilang support brings its own can of worms: bloated bundle size for client and exploding string cache for server to name a few.
I have the following schema
and following data
Now when I validate the schema, the I get the following error
My code
What I am looking for is a descriptive error similar to what cfworker/json-schema throws
Items did not match schema. Instance type "number" is invalid. Expected "string".