Add strict mode for JSON Schema validation

Are you missing a feature? Request it's implementation here.
sspringett
Posts: 2
Joined: Sat May 25, 2019 5:19 pm

Add strict mode for JSON Schema validation

Post by sspringett » Thu Apr 30, 2020 5:55 am

The JSON schema group has consistently rejected strict validation modes - see https://github.com/json-schema-org/json ... issues/682

However, as an author of JSON schemas, this is a really useful feature, which I wished JSON schema supported. When testing a JSON document against a JSON schema which I've created, I'd like to know if the JSON document is being validated strictly based on the properties defined in the schema, or if there were undefined properties in the JSON document.

Due to JSON schema not supporting strict validation, it's not simple to create test cases for positive validation. It's possible, but results in a lot of extra work just to perform positive test cases.

I would like some kind of feedback in Oxygen that the document I'm validating strictly conforms to a given schema (uses only the properties and property patterns defined), or validates loosely. If loose validation detected, I'd like information as to what properties are not defined in the schema.

Thanks and keep up the great work!

tavy
Posts: 228
Joined: Thu Jul 01, 2004 12:29 pm

Re: Add strict mode for JSON Schema validation

Post by tavy » Thu Apr 30, 2020 4:13 pm

Hello,

Thanks for your feedback.
For JSON Schema validation, we automatically show warnings for each property that is not recognized in the current schema version.
For the validation of a JSON instance with a JSON Schema, you need to add in the JSON Schema the "additionalProperties": false construct on each property definition. This means that only the defined properties are allowed to be inserted as child, any other property will be marked as invalid.
Maybe we could add an option for strict validation of JSON instances, but this will be in conflict with the "additionalProperties" values from the JSON Schema. This option will overwrite all the "additionalProperties" from the JSON Schema, and set them to false.

Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply