-
Notifications
You must be signed in to change notification settings - Fork 63
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
2600hz changes #42
2600hz changes #42
Conversation
the fixes the mix between draft3/draft4 schemas
wraps the logic of validating referenced schemas
this will extra validations for schema elements example : lookup some value in a database an provide an error
allows to set values during validation
persistence depends on setter_fun option
11536f6
to
a4bf90f
Compare
default error handler
src/jesse_state.erl
Outdated
@@ -192,7 +192,7 @@ resolve_ref(State, Reference) -> | |||
Path = jesse_json_path:parse(Pointer), | |||
case load_local_schema(State#state.root_schema, Path) of | |||
?not_found -> | |||
jesse_error:handle_schema_invalid(?schema_invalid, State); | |||
jesse_error:handle_schema_invalid(Reference, State); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't the $ref
already part of the error?
I've cherry-picked your change, and instead output the canonical reference (the output from combine_id
). That is slightly more valuable i.e. see how the $ref
was expanding, and see what jesse tried to find and load.
src/jesse_schema_validator.hrl
Outdated
@@ -112,6 +112,7 @@ | |||
-define(not_one_schema_valid, 'not_one_schema_valid'). | |||
-define(not_schema_valid, 'not_schema_valid'). | |||
-define(wrong_not_schema, 'wrong_not_schema'). | |||
-define(external_error, 'external_error'). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see the sugar-power for this change, and I've been tempted to do similar, but explain to me why wouldn't you first validate with jesse and then validate for more (e.g. realtime semantics), rather than call a function for all nested values (while I assume you're only interested in validate a handful) ?
src/jesse_error.erl
Outdated
@@ -64,7 +64,7 @@ | |||
) -> [error_reason()] | no_return(). | |||
default_error_handler(Error, ErrorList, AllowedErrors) -> | |||
case AllowedErrors > length(ErrorList) orelse AllowedErrors =:= 'infinity' of | |||
true -> [Error | ErrorList]; | |||
true -> ErrorList ++ [Error]; | |||
false -> throw([Error | ErrorList]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this fix also apply to the false branch ?
would you care to give some detailed rationale for
thanks |
@andreineculau for example below for getting defaults for a schema
|
@lazedo thanks for the clear explanation! I can only think of two requests:
Wdyt? |
@andreineculau i'm ok with adding the use_default and we can default it to |
@andreineculau i ended up adding a 'validator_options' to control the defaults behaviour. this last is to bypass a recursive default {} with {$ref, #} let me know if you agree or if there's anything else needed to wok on. |
@andreineculau hi, anything else required here ? |
needed when allowed_errors is `infinity`
yes, I'm required :( and I'm finding it hard to get time on my hands
…On Mon, Mar 27, 2017 at 7:08 PM, lazedo ***@***.***> wrote:
@andreineculau <https://github.com/andreineculau> hi, anything else
required here ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#42 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AArOQWLNfrnhFCMw7ENPjjsfCkP99pF_ks5rp-0QgaJpZM4MLSoq>
.
--
andreineculau.com <http://www.andreineculau.com>
|
@andreineculau ping. we would love to create a 1.5 release after this merge |
when is_binary(Type) -> | ||
check_default_for_type(Default, State) | ||
andalso is_type_valid(Default, Type, State); | ||
is_valid_default(Types, Default, State) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Types - typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expressing that in this clause we're dealing with a list used in lists:any
some changes that fix/enhance jesse