justify icon indicating copy to clipboard operation
justify copied to clipboard

Custom keywords impl support

Open Navgeet opened this issue 4 years ago • 2 comments

Hi, my company is considering using this library. We want to be able to extend the JSON Schema spec with custom keywords, but it is not currently supported. I would be happy to discuss this change with you and contribute.

I tried implementing a range keyword as described in 1. I ran into these problems:

  • The base keyword classes (AbstractNumericAssertion) are private, and can't be extended in my own package.
  • ProblemBuilder withMessage builder method requires Message as argument. I think it would be better if it accepts BaseMessage, which should be a public interface I can implement.
  • I'm not yet sure how to inject my own keyword into Justify, but StandardKeywordFactory seems to be the way. Maybe it can have an addKeyword method?

Happy to help, if you have an API in mind, I can come up with an impl. Thanks for this great project!

Navgeet avatar May 11 '20 11:05 Navgeet

@Navgeet There are two challenging tasks left for me in this project.

  1. Implement the latest specification draft 2019-09 (see #29)
  2. Implement mechanism for users to extend the validator with their own custom keywords, as you requested

I am currently working on the first task. The latest specification will introduce a new concept vocabulary, which is a unit for grouping schema keywords. The concept may force me to change the software design relating to schema keywords and may also provide an impact on the extension API for custom keywords. Could you please wait for me to improve the current design in order to accommodate the latest specification?

leadpony avatar May 12 '20 09:05 leadpony

Sure, makes sense.

Navgeet avatar May 12 '20 15:05 Navgeet