3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/rails_uploads/validators/attachment_size_validator.rb', line 3
def validate_each(record, attribute, value)
if value.present? and not value.is_default?
if options.has_key? :in
unless options[:in].include? value.size
add_error record, attribute, 'attachment_size_in', greater_than: options[:in].begin, less_than: options[:in].end
end
else
if options.has_key? :less_than and value.size > options[:less_than]
add_error record, attribute, 'attachment_size_less_than', less_than: options[:less_than]
end
if options.has_key? :greater_than and value.size < options[:greater_than]
add_error record, attribute, 'attachment_size_greater_than', greater_than: options[:greater_than]
end
end
end
end
|