codegram / date_validator

A simple, ORM agnostic, Ruby >=2.2 compatible date validator for Rails, based on ActiveModel.
http://thoughts.codegram.com/date-validation-with-rails-3
MIT License
495 stars 82 forks source link

I18n conflicts with Activemodel I18n #65

Closed be9 closed 3 years ago

be9 commented 9 years ago

ActiveModel contains own definition of errors.messages.equal_to, as seen in here. date_validator redefines it here which causes breakage. E.g. I get following in my specs:

    I18n::MissingInterpolationArgument:
       missing interpolation argument :date in "must be equal to %{date}" ({:model=>"Site", :attribute=>"Monthly payment", :value=>1.0, :count=>0} given)

ActiveModel variant is "must be equal to %{count}" and it works if date_validator is not loaded.

dolzenko commented 9 years ago

Same issue here, I assume date_validator should use namespaced errors?

As a temp fix I had to add this to my locale file:

en:
  activerecord:
    errors:
      messages:
        equal_to: "must be equal to %{count}"
thibaudgg commented 9 years ago

:+1:

eebs commented 8 years ago

I have run into this problem as well. @dolzenko's fix worked for me as well, but I presume this would break date_validator's equal_to option message.

mrcasals commented 3 years ago

Closed by #77