Skip to content

Commit 4e368e6

Browse files
committed
Merge pull request #20 from kv109/master
allow maxlength validation for inputs which can be blank
2 parents 77f9e8d + 0a9b5b4 commit 4e368e6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/html5_validators/active_model/helper_methods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def attribute_required?(attribute)
99

1010
def attribute_maxlength(attribute)
1111
self.validators.grep(LengthValidator).select {|v|
12-
v.attributes.include?(attribute.to_sym) && (v.options.keys & [:maximum, :is]).any? && (v.options.keys & [:if, :unless, :allow_nil, :allow_blank, :tokenizer]).empty?
12+
v.attributes.include?(attribute.to_sym) && (v.options.keys & [:maximum, :is]).any? && (v.options.keys & [:if, :unless, :tokenizer]).empty?
1313
}.map {|v| v.options.slice(:maximum, :is)}.map(&:values).flatten.max
1414
end
1515

0 commit comments

Comments
 (0)