Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) Date Validation Error Messages #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/validators/date.ex
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ defmodule EctoCommons.DateValidator do
defp wrong_date(%Date{} = value, is, nil, opts) do
case Date.compare(value, is) do
:eq -> nil
_ -> {message(opts, "should be %{is}."), validation: :datetime, kind: :is}
_ -> {message(opts, "should be #{is}."), validation: :datetime, kind: :is}
end
end

Expand All @@ -138,7 +138,7 @@ defmodule EctoCommons.DateValidator do
_ ->
case abs(Date.diff(value, is)) do
val when val > delta ->
{message(opts, "should be %{is}."), validation: :datetime, kind: :is}
{message(opts, "should be #{is}."), validation: :datetime, kind: :is}

_ ->
nil
Expand All @@ -151,7 +151,7 @@ defmodule EctoCommons.DateValidator do
defp too_soon(%Date{} = value, afterr, opts) do
case Date.compare(value, afterr) do
:gt -> nil
_ -> {message(opts, "should be after %{after}."), validation: :datetime, kind: :after}
_ -> {message(opts, "should be after #{afterr}."), validation: :datetime, kind: :after}
end
end

Expand All @@ -160,7 +160,7 @@ defmodule EctoCommons.DateValidator do
defp too_late(%Date{} = value, before, opts) do
case Date.compare(value, before) do
:lt -> nil
_ -> {message(opts, "should be before %{before}."), validation: :datetime, kind: :before}
_ -> {message(opts, "should be before #{before}."), validation: :datetime, kind: :before}
end
end

Expand Down