Skip to content

Commit

Permalink
refactor: rename method to check_size_with_op
Browse files Browse the repository at this point in the history
  • Loading branch information
heywhy committed Feb 3, 2025
1 parent 1f595ff commit 7c9556e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/validator/rules.ex
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ defmodule Request.Validator.Rules do
)
}

check_with_op(value, bound, &Kernel.>=/2, messages)
check_size_with_op(value, bound, &Kernel.>=/2, messages)
end

&validator_fn.(bound, &1, &2)
Expand Down Expand Up @@ -545,7 +545,7 @@ defmodule Request.Validator.Rules do
)
}

check_with_op(value, bound, &Kernel.<=/2, messages)
check_size_with_op(value, bound, &Kernel.<=/2, messages)
end

&validator_fn.(bound, &1, &2)
Expand Down Expand Up @@ -613,13 +613,13 @@ defmodule Request.Validator.Rules do

cond do
is_nil(compared_value) and (is_number(value) and is_number(bound)) ->
check_with_op(value, bound, &Kernel.>/2, messages)
check_size_with_op(value, bound, &Kernel.>/2, messages)

is_number(bound) ->
{:error, messages.string}

same_type?(value, compared_value) ->
check_with_op(value, compared_value, &Kernel.>/2, messages)
check_size_with_op(value, compared_value, &Kernel.>/2, messages)

true ->
{:error, messages.string}
Expand Down Expand Up @@ -691,13 +691,13 @@ defmodule Request.Validator.Rules do

cond do
is_nil(compared_value) and (is_number(value) and is_number(bound)) ->
check_with_op(value, bound, &Kernel.</2, messages)
check_size_with_op(value, bound, &Kernel.</2, messages)

is_number(bound) ->
{:error, messages.string}

same_type?(value, compared_value) ->
check_with_op(value, compared_value, &Kernel.</2, messages)
check_size_with_op(value, compared_value, &Kernel.</2, messages)

true ->
{:error, messages.string}
Expand Down Expand Up @@ -769,13 +769,13 @@ defmodule Request.Validator.Rules do

cond do
is_nil(compared_value) and (is_number(value) and is_number(bound)) ->
check_with_op(value, bound, &Kernel.>=/2, messages)
check_size_with_op(value, bound, &Kernel.>=/2, messages)

is_number(bound) ->
{:error, messages.string}

same_type?(value, compared_value) ->
check_with_op(value, compared_value, &Kernel.>=/2, messages)
check_size_with_op(value, compared_value, &Kernel.>=/2, messages)

true ->
{:error, messages.string}
Expand Down Expand Up @@ -847,13 +847,13 @@ defmodule Request.Validator.Rules do

cond do
is_nil(compared_value) and (is_number(value) and is_number(bound)) ->
check_with_op(value, bound, &Kernel.<=/2, messages)
check_size_with_op(value, bound, &Kernel.<=/2, messages)

is_number(bound) ->
{:error, messages.string}

same_type?(value, compared_value) ->
check_with_op(value, compared_value, &Kernel.<=/2, messages)
check_size_with_op(value, compared_value, &Kernel.<=/2, messages)

true ->
{:error, messages.string}
Expand Down Expand Up @@ -900,7 +900,7 @@ defmodule Request.Validator.Rules do
)
}

check_with_op(value, bound, &Kernel.==/2, messages)
check_size_with_op(value, bound, &Kernel.==/2, messages)
end

&validator_fn.(bound, &1, &2)
Expand Down Expand Up @@ -1043,7 +1043,7 @@ defmodule Request.Validator.Rules do
|> Enum.empty?()
end

defp check_with_op(first, second, op, messages) do
defp check_size_with_op(first, second, op, messages) do
message =
case messages do
%{} -> messages[get_type(first)]
Expand Down

0 comments on commit 7c9556e

Please sign in to comment.