2
3
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/mongoid_time_field/validator.rb', line 2
def validate_each(record, attribute, value)
unless options[:less_than].blank?
unless value < Mongoid::TimeField::Value.new(options[:less_than], value.format)
record.errors.add attribute, (options[:message] || "должно быть меньше #{options[:less_than]}")
end
end
unless options[:greater_than].blank?
unless value > Mongoid::TimeField::Value.new(options[:greater_than], value.format)
record.errors.add attribute, (options[:message] || "должно быть больше #{options[:greater_than]}")
end
end
end
|