Skip to content

Commit

Permalink
$ref should ignore any other properties re #47
Browse files Browse the repository at this point in the history
  • Loading branch information
andreineculau committed May 22, 2017
1 parent 4160f98 commit 8173196
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/jesse_validator_draft3.erl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
, JsonSchema :: jesse:json_term()
, State :: jesse_state:state()
) -> jesse_state:state() | no_return().
check_value(Value, [{?REF, RefSchemaURI} | _Attrs], State) ->
validate_ref(Value, RefSchemaURI, State);

This comment has been minimized.

Copy link
@seriyps

seriyps May 22, 2017

Contributor

Looks like this is not a complete solution, because schema may look like

{[
{<<"type">>, <..>},
{<<"enum">>, <..>},
...
{<<"$ref">>, <..>}
]}

And in this case all checks will be performed, because $ref is the last one in a list.

This comment has been minimized.

Copy link
@andreineculau

andreineculau via email May 23, 2017

Author Member
check_value(Value, [{?TYPE, Type} | Attrs], State) ->
NewState = check_type(Value, Type, State),
check_value(Value, Attrs, NewState);
Expand Down Expand Up @@ -210,9 +212,6 @@ check_value(Value, [{?DISALLOW, Disallow} | Attrs], State) ->
check_value(Value, [{?EXTENDS, Extends} | Attrs], State) ->
NewState = check_extends(Value, Extends, State),
check_value(Value, Attrs, NewState);
check_value(Value, [{?REF, RefSchemaURI} | Attrs], State) ->
NewState = validate_ref(Value, RefSchemaURI, State),
check_value(Value, Attrs, NewState);
check_value(Value, [], State) ->
maybe_external_check_value(Value, State);
check_value(Value, [_Attr | Attrs], State) ->
Expand Down
5 changes: 2 additions & 3 deletions src/jesse_validator_draft4.erl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
, JsonSchema :: jesse:json_term()
, State :: jesse_state:state()
) -> jesse_state:state() | no_return().
check_value(Value, [{?REF, RefSchemaURI} | _Attrs], State) ->
validate_ref(Value, RefSchemaURI, State);
check_value(Value, [{?TYPE, Type} | Attrs], State) ->
NewState = check_type(Value, Type, State),
check_value(Value, Attrs, NewState);
Expand Down Expand Up @@ -247,9 +249,6 @@ check_value(Value, [{?ONEOF, Schemas} | Attrs], State) ->
check_value(Value, [{?NOT, Schema} | Attrs], State) ->
NewState = check_not(Value, Schema, State),
check_value(Value, Attrs, NewState);
check_value(Value, [{?REF, RefSchemaURI} | Attrs], State) ->
NewState = validate_ref(Value, RefSchemaURI, State),
check_value(Value, Attrs, NewState);
check_value(Value, [], State) ->
maybe_external_check_value(Value, State);
check_value(Value, [_Attr | Attrs], State) ->
Expand Down

0 comments on commit 8173196

Please sign in to comment.