Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error messages when runtime type checking fails #1

Open
jvilk opened this issue Dec 18, 2016 · 1 comment
Open

Better error messages when runtime type checking fails #1

jvilk opened this issue Dec 18, 2016 · 1 comment

Comments

@jvilk
Copy link
Owner

jvilk commented Dec 18, 2016

What's a good way to have decent error messages without adding too much overhead / context tracking embedded in the JSON objects?

@plievone
Copy link

If you would emit json-schemas, then one could use ajv for runtime error reporting. I like it because then I can use the same schema to (A) validate strictly (throw errors etc, like MakeTypes does), or (B) ensure valid type by assigning defaults to required fields and using type coercion. Usually one needs to filter additional properties with removeAdditional, but sometimes APIs use objects as hashes where index types are needed. In that case it is good to filter out Object.prototype properties at least so that the resulting objects are well-behaving in runtime. So there could be all kinds of intricacies to get json-schemas work, but it might be worth it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants