Skip to content

Commit

Permalink
Merge pull request #128 from sile/fix-otp-master-warnings
Browse files Browse the repository at this point in the history
Use `== 0.0` to check if the value is zero instead of pattern matching to fix warnings in the OTP master
  • Loading branch information
seriyps authored Sep 29, 2023
2 parents 1fc2703 + bc00493 commit cf075d2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/jesse_validator_draft3.erl
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,8 @@ check_divisible_by(Value, 0, 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 ->
case Result == 0.0 of
true ->
State;
_ ->
handle_data_invalid(?not_divisible, Value, State)
Expand Down
4 changes: 2 additions & 2 deletions src/jesse_validator_draft4.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1015,8 +1015,8 @@ check_format(_Value, _Format, State) ->
check_multiple_of(Value, MultipleOf, State)
when is_number(MultipleOf), MultipleOf > 0 ->
Result = (Value / MultipleOf - trunc(Value / MultipleOf)) * MultipleOf,
case Result of
0.0 ->
case Result == 0.0 of
true ->
State;
_ ->
handle_data_invalid(?not_multiple_of, Value, State)
Expand Down
4 changes: 2 additions & 2 deletions src/jesse_validator_draft6.erl
Original file line number Diff line number Diff line change
Expand Up @@ -993,8 +993,8 @@ uri_reference(_Value, State) ->
%% @private
check_multiple_of(Value, MultipleOf, State)
when is_number(MultipleOf), MultipleOf > 0 ->
try (Value / MultipleOf - trunc(Value / MultipleOf)) * MultipleOf of
0.0 ->
try (Value / MultipleOf - trunc(Value / MultipleOf)) * MultipleOf == 0.0 of
true ->
State;
_ ->
handle_data_invalid(?not_multiple_of, Value, State)
Expand Down

0 comments on commit cf075d2

Please sign in to comment.