-
Notifications
You must be signed in to change notification settings - Fork 64
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
anyOf / OneOf returns unexpected error with allowed_errors=infinity #80
Comments
I believe the problem might be here: jesse/src/jesse_validator_draft4.erl Lines 1142 to 1146 in 9f9d050
If I believe what should be done is that we should reset |
Ok, this does the trick: diff --git a/src/jesse_validator_draft4.erl b/src/jesse_validator_draft4.erl
index 0583d3f..1a36402 100644
--- a/src/jesse_validator_draft4.erl
+++ b/src/jesse_validator_draft4.erl
@@ -1139,10 +1139,11 @@ check_any_of(_Value, _InvalidSchemas, State) ->
check_any_of_(Value, [], State) ->
handle_data_invalid(?any_schemas_not_valid, Value, State);
check_any_of_(Value, [Schema | Schemas], State) ->
+ NumErrsBefore = length(jesse_state:get_error_list(State)),
case validate_schema(Value, Schema, State) of
{true, NewState} ->
- case jesse_state:get_error_list(NewState) of
- [] -> NewState;
+ case length(jesse_state:get_error_list(NewState)) of
+ NumErrsBefore -> NewState;
_ -> check_any_of_(Value, Schemas, State)
end;
{false, _} -> check_any_of_(Value, Schemas, State)
@@ -1176,10 +1177,11 @@ check_one_of_(Value, [], State, 0) ->
check_one_of_(Value, _Schemas, State, Valid) when Valid > 1 ->
handle_data_invalid(?not_one_schema_valid, Value, State);
check_one_of_(Value, [Schema | Schemas], State, Valid) ->
+ NumErrsBefore = length(jesse_state:get_error_list(State)),
case validate_schema(Value, Schema, State) of
{true, NewState} ->
- case jesse_state:get_error_list(NewState) of
- [] -> check_one_of_(Value, Schemas, NewState, Valid + 1);
+ case length(jesse_state:get_error_list(NewState)) of
+ NumErrsBefore -> check_one_of_(Value, Schemas, NewState, Valid + 1);
_ -> check_one_of_(Value, Schemas, State, Valid)
end;
{false, _} -> Will try to make a PR |
Might be caused by fix for #22
Minimized example:
data.json
schema.json
I expect it to only generate
no_extra_properties_allowed
, but it also generatesany_schemas_not_valid
The text was updated successfully, but these errors were encountered: