davishmcclurg / json_schemer

JSON Schema validator. Supports drafts 4, 6, 7, 2019-09, 2020-12, OpenAPI 3.0, and OpenAPI 3.1.
MIT License
398 stars 65 forks source link

Add support (or README note) for custom keyword validation #195

Open ekzobrain opened 3 weeks ago

ekzobrain commented 3 weeks ago

We need to extend schema validation with custom keywords. We may describe them with additional vocabularies, but we also need to make an implementation for them to be validatable. How may it be implemented? It would be great to have an official support for extending validation keyword implementation. May be it is already possible, and a README paragraph would be sufficient. For example, we need to add support for this: https://github.com/ajv-validator/ajv-keywords?tab=readme-ov-file#uniqueitemproperties

davishmcclurg commented 3 weeks ago

There is some limited support for custom keywords. It's undocumented because it's not well supported, but you can check out the tests for examples, eg: https://github.com/davishmcclurg/json_schemer/blob/1878fe873c2f9248b0946aeaeaa18c227ece6374/test/json_schemer_test.rb#L180-L211

We may describe them with additional vocabularies, but we also need to make an implementation for them to be validatable. How may it be implemented? It would be great to have an official support for extending validation keyword implementation.

Ideally, I'd like to support custom keywords via custom vocabularies, but I have not done any work on that. Please let me know if you're interested in contributing!

davishmcclurg commented 3 weeks ago

More info: