13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/active_validation/validators/file_size_validator.rb', line 13
def validate_each(record, attribute, value)
assert_valid_options!
values = parse_values(value)
return if values.empty?
options.slice(*CHECKS.keys).each do |option, option_value|
option_value = option_value.call(record) if option_value.is_a?(Proc)
next unless values.any? { |val| !valid_size?(val.size, option, option_value) }
error_text = filtered_options(values).merge!(detect_error_options(option_value))
error_text = options[:message] ||
I18n.t("active_validation.errors.messages.file_size.#{option}", error_text)
record.errors[attribute] << (options[:message] || error_text)
end
end
|