8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/tuning/validations/time.rb', line 8
def validate_each(record, attribute, value)
if [Date, Time].any? { |klass| value.kind_of?(klass) }
CHECKS.each do |name, operator|
if options.has_key?(name)
other = options[name]
case other
when Symbol
other = record.send(other)
when Proc
other = other.call(record)
end
unless value.send(operator, other)
record.errors.add attribute, name, time: I18n.l(other)
end
end
end
else
record.errors.add attribute, :not_a_time
end
end
|