jonasschmidt / ex_json_schema

An Elixir JSON Schema validator
MIT License
366 stars 98 forks source link

Unknown validators by typo are always valid #26

Closed tokubass closed 6 years ago

tokubass commented 6 years ago

The following test succeed due to typo.

 assert valid?(%{"typee" =>  "integer" }, "a") == true

What is the correct way to prevent typo ?

jonasschmidt commented 6 years ago

JSON Schema ignores additional/unknown properties in the schema (like typee in your example) in order to be easily extensible. You can have a look at the draft 4 meta-schema here: http://json-schema.org/draft-04/schema (it's surprisingly simple).

I don't think that's something that can be solved on a library level, because people could use their schema to add all sorts of additional properties. You could define your own meta-schema (based on the draft 4 meta-schema) and use that custom meta-schema to validate your schema.

tokubass commented 6 years ago

thank you. I wil try locking properties on a application level.