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

Optionally warn on additional properties/items (regardless of schema) #501

Closed
brettz9 opened this issue May 24, 2017 · 4 comments
Closed

Comments

@brettz9
Copy link

brettz9 commented May 24, 2017

What version of Ajv you are you using? 5.1.3

What problem do you want to solve? Ensure instance does not have unintentionally misplaced properties (regardless of whether additionalProperties: false (or additionalItems: false) is set on the schema since one may not wish to impose this on all consumers of the schema).

What do you think is the correct solution to problem? Allow config to Ajv which supports reporting all unknown properties or items (including if applying to schema files). The reporting could be ignored if additionalProperties (or additionalItems) was set within the schema.

Will you be able to implement it? I don't think so--hands way too full atm.

@epoberezkin
Copy link
Member

see #379

@brettz9
Copy link
Author

brettz9 commented May 25, 2017

I'm having trouble with that approach as a simple valid schema (supplied as data) gets stripped to nothing when validated using removeAdditional set to all against the draft 4 schema: https://runkit.com/brettz9/59263cf6466ac600128cb264 .

If this is due to problems with removeAdditional with additionalProperties, it seems that the burden requiring refactoring is a heavy one, as schemas such as the JSON Schema meta-schema may not be under one's direct control.

@epoberezkin
Copy link
Member

Doing it with the schema complicates it a bit, but can be done too:

https://runkit.com/esp/59268e4e237c55001294fda2

#379 also suggests a custom keyword

@brettz9
Copy link
Author

brettz9 commented May 25, 2017

Thanks! It looks like validateSchema: false is the critical piece here rather than the meta: false.

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

No branches or pull requests

2 participants