mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +00:00
added deprecation notice for :equal_to
This commit is contained in:
parent
59d9957ab6
commit
f1a0016bf7
@ -1,3 +1,4 @@
|
||||
#TODO remove deprecated option :equal_to
|
||||
module ValidatesTimeliness
|
||||
|
||||
class Validator
|
||||
@ -7,6 +8,7 @@ module ValidatesTimeliness
|
||||
|
||||
RESTRICTION_METHODS = {
|
||||
:is_at => :==,
|
||||
:equal_to => :==,
|
||||
:before => :<,
|
||||
:after => :>,
|
||||
:on_or_before => :<=,
|
||||
@ -140,6 +142,12 @@ module ValidatesTimeliness
|
||||
end
|
||||
|
||||
def validate_options(options)
|
||||
if options.key?(:equal_to)
|
||||
::ActiveSupport::Deprecation.warn("ValidatesTimeliness :equal_to option is deprecated due to clash with a default Rails option. Use :is_at instead. You will need to fix any I18n error message references to this option date/time attributes now.")
|
||||
options[:is_at] = options.delete(:equal_to)
|
||||
options[:is_at_message] = options.delete(:equal_to_message)
|
||||
end
|
||||
|
||||
invalid_for_type = ([:time, :date, :datetime] - [type]).map {|k| "invalid_#{k}_message".to_sym }
|
||||
invalid_for_type << :with_date unless type == :time
|
||||
invalid_for_type << :with_time unless type == :date
|
||||
|
||||
Loading…
Reference in New Issue
Block a user