Aligning code and using macro for not_divisible, klarna/jesse#13

This commit is contained in:
Viktor Söderqvist 2014-02-14 17:01:34 +01:00
parent 837cec5ae3
commit ddfd82f68e

View File

@ -448,7 +448,7 @@ check_properties(Value, Properties, State) ->
NewState = set_current_schema( CurrentState
, PropertySchema
),
check_value(PropertyName
check_value( PropertyName
, Property
, unwrap(PropertySchema)
, NewState
@ -633,8 +633,8 @@ check_items_fun(Tuples, State) ->
NewState = set_current_schema( CurrentState
, Schema
),
{ Index + 1,
check_value(Index, Item, unwrap(Schema),
{ Index + 1
, check_value(Index, Item, unwrap(Schema),
NewState)
}
end
@ -918,14 +918,14 @@ check_format(_Value, _Format, State) ->
%% integer.) The value of this attribute SHOULD NOT be 0.
%% @private
check_divisible_by(Value, 0, State) ->
handle_data_invalid('not_divisible', Value, State);
handle_data_invalid(?not_divisible, Value, State);
check_divisible_by(Value, DivisibleBy, State) ->
Result = (Value / DivisibleBy - trunc(Value / DivisibleBy)) * DivisibleBy,
case Result of
0.0 ->
State;
_ ->
handle_data_invalid('not_divisible', Value, State)
handle_data_invalid(?not_divisible, Value, State)
end.
%% @doc 5.25. disallow