Add support for configurable and extendable validators#55
Add support for configurable and extendable validators#55arentrue wants to merge 1 commit intofor-GET:no-external-validatorfrom
Conversation
|
@arentrue i think the initial external validators may not be fully explained. we have draft3/draft4 schemas that validate data, and.., for business extensions (validate a customer in a database, ....) we use the extension validator by using the callback. we look for annotated schema elements and perform whatever we want as an extra validation. |
|
@lazedo thanks for the explanation. Yes, that is also clear from the code and description in your initial PR. The reason I still propose this PR is because it provides a superset of the functionality you've implementated. In addition to the extra validation of annotated schema elements on top of draft4/draft3 it allows easily override original validation logic of a base validator (e.g. draft3 or draft4) for particular schema element. It also allows to create a new custom validator modules altogether. In my opinion, it also corrects the initial validation API in jesse, moving the looping over schema into the common |
|
@arentrue thanks for the reply, but how would you validate a draft4+(custom for a single field)? |
| [] -> State | ||
| end; | ||
| check_value(Value, Attr, State) -> | ||
| jesse_validator_draft4:check_value(Value, Attr, State). |
There was a problem hiding this comment.
@lazedo answering your question in the main thread, here is an example in tests.
The customDef schema parameter is validated on top of draft4 schema, with a custom logic.
|
Note that we're now working on standardizing how schemas can be extended. json-schema-org/json-schema-spec#602 is an example. It's working through some particularly complex cases involving newly proposed keywords, and it's a lot of ideas that are new and somewhat tentative. But anyone who is interested in making extensible implementations may want to look at that issue and json-schema-org/json-schema-spec#561 |
This is one of the two PRs which are the result of PR #53 split.