Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for configurable and extendable validators #55

Open
wants to merge 1 commit into
base: no-external-validator
Choose a base branch
from

Conversation

arentrue
Copy link

@arentrue arentrue commented May 23, 2017

This is one of the two PRs which are the result of PR #53 split.

@arentrue arentrue changed the title Add suppport for configurable and extendable validators Add support for configurable and extendable validators May 23, 2017
@lazedo
Copy link
Contributor

lazedo commented May 30, 2017

@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.
we still want to use v3/v4 validators for types, ranges, whatever. we are only interested in providing an extra layer of validation not tied to jesse core library not replacing by a custom validator.

@arentrue
Copy link
Author

@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 jesse_schema_validator module and leaving validator modules only pure validation functionality with a clean interface for that.

@lazedo
Copy link
Contributor

lazedo commented Jun 13, 2017

@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).
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

@andreineculau andreineculau added this to the next major milestone May 17, 2018
@handrews
Copy link

handrews commented Jun 6, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants