adzap / validates_timeliness

Date and time validation plugin for ActiveModel and Rails. Supports multiple ORMs and allows custom date/time formats.
MIT License
1.59k stars 227 forks source link

Is there syntax to custom validate #126

Closed dieuit07 closed 9 years ago

dieuit07 commented 9 years ago

Example:

validates_datetime :public_date, :on_or_after => :release_date

Error is not good enough for client understand :

Public date must be on or after 2015-07-01 09:33:00

I recommend it should be :)

Public date must be on or after 2015-07-01 09:33:00 (release date)
adzap commented 9 years ago

You can override any validation message in the locale file per attribute or with the message option key

validates_datetime :public_date, :on_or_after => :release_date, :on_or_after_message => "must be on or after %{restriction} (release date)"

We wouldn't use the symbol as anything such as a name in the message. The symbol could be any method which may not semantically represent the value to the user.