diff --git a/lib/vex/blank.ex b/lib/vex/blank.ex index 18c92a5..99f3e02 100644 --- a/lib/vex/blank.ex +++ b/lib/vex/blank.ex @@ -36,8 +36,7 @@ defimpl Vex.Blank, for: Map do def blank?(map), do: map_size(map) == 0 end -defimpl Vex.Blank, for: [Date, DateTime, NaiveDateTime] do - def blank?(nil), do: true +defimpl Vex.Blank, for: [Date, DateTime, NaiveDateTime, Time] do def blank?(_), do: false end diff --git a/test/validations/presence_test.exs b/test/validations/presence_test.exs index df8eb69..6b99a71 100644 --- a/test/validations/presence_test.exs +++ b/test/validations/presence_test.exs @@ -15,8 +15,7 @@ defmodule PresenceTest do assert Vex.valid?([date: Date.utc_today()], date: [presence: true]) assert Vex.valid?([date: NaiveDateTime.utc_now()], date: [presence: true]) assert Vex.valid?([date: DateTime.utc_now()], date: [presence: true]) - refute Vex.valid?([date: nil], date: [presence: true]) - refute Vex.valid?([date: nil], date: [presence: true]) + assert Vex.valid?([date: Time.utc_now()], date: [presence: true]) refute Vex.valid?([date: nil], date: [presence: true]) end @@ -40,9 +39,8 @@ defmodule PresenceTest do assert Vex.valid?(%{"date" => Date.utc_today()}, %{"date" => [presence: true]}) assert Vex.valid?(%{"date" => DateTime.utc_now()}, %{"date" => [presence: true]}) assert Vex.valid?(%{"date" => NaiveDateTime.utc_now()}, %{"date" => [presence: true]}) - refute Vex.valid?([date: nil], %{"date" => [presence: true]}) - refute Vex.valid?([date: nil], %{"date" => [presence: true]}) - refute Vex.valid?([date: nil], %{"date" => [presence: true]}) + assert Vex.valid?(%{"date" => Time.utc_now()}, %{"date" => [presence: true]}) + refute Vex.valid?(%{"date" => nil}, %{"date" => [presence: true]}) end test "keyword list, included presence validation" do