$ref should not have other sibling properties. fix #54

This commit is contained in:
Andrei Neculau 2018-02-13 14:33:42 +01:00
parent 28dd963cd2
commit de3f1cbb47
3 changed files with 15 additions and 4 deletions

View File

@ -82,6 +82,7 @@
%% Constant definitions for schema errors
-define(invalid_dependency, 'invalid_dependency').
-define(only_ref_allowed, 'only_ref_allowed').
-define(schema_invalid, 'schema_invalid').
-define(schema_not_found, 'schema_not_found').
-define(schema_unsupported, 'schema_unsupported').

View File

@ -61,8 +61,13 @@
, JsonSchema :: jesse:schema()
, State :: jesse_state:state()
) -> jesse_state:state() | no_return().
check_value(Value, [{?REF, RefSchemaURI} | _Attrs], State) ->
validate_ref(Value, RefSchemaURI, State);
check_value(Value, [{?REF, RefSchemaURI} | Attrs], State) ->
case Attrs of
[] ->
validate_ref(Value, RefSchemaURI, State);
_ ->
handle_schema_invalid(?only_ref_allowed, State)
end;
check_value(Value, [{?TYPE, Type} | Attrs], State) ->
NewState = check_type(Value, Type, State),
check_value(Value, Attrs, NewState);

View File

@ -78,8 +78,13 @@
, JsonSchema :: jesse:schema()
, State :: jesse_state:state()
) -> jesse_state:state() | no_return().
check_value(Value, [{?REF, RefSchemaURI} | _Attrs], State) ->
validate_ref(Value, RefSchemaURI, State);
check_value(Value, [{?REF, RefSchemaURI} | Attrs], State) ->
case Attrs of
[] ->
validate_ref(Value, RefSchemaURI, State);
_ ->
handle_schema_invalid(?only_ref_allowed, State)
end;
check_value(Value, [{?TYPE, Type} | Attrs], State) ->
NewState = check_type(Value, Type, State),
check_value(Value, Attrs, NewState);