Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #7253 from acapilleri/lenght_validator_errors_options

calculate errors_options one time in validate_each
  • Loading branch information...
commit 9895f6ca2b235873c26f9526760b096a7bc3e002 2 parents c8a613b + 93b6faf
@rafaelfranca rafaelfranca authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 activemodel/lib/active_model/validations/length.rb
View
4 activemodel/lib/active_model/validations/length.rb
@@ -36,12 +36,12 @@ def check_validity!
def validate_each(record, attribute, value)
value = tokenize(value)
value_length = value.respond_to?(:length) ? value.length : value.to_s.length
-
+ errors_options = options.except(*RESERVED_OPTIONS)
+
CHECKS.each do |key, validity_check|
next unless check_value = options[key]
next if value_length.send(validity_check, check_value)
- errors_options = options.except(*RESERVED_OPTIONS)
errors_options[:count] = check_value
default_message = options[MESSAGES[key]]
Please sign in to comment.
Something went wrong with that request. Please try again.