Permalink
Browse files

Check by the validation kind method instead of the full constant

  • Loading branch information...
1 parent de29633 commit 274d6ec111da186dbbef6f0c4e161aac496850d7 @rafaelfranca rafaelfranca committed Oct 3, 2012
@@ -23,7 +23,7 @@ def maximum_length_from_validation
end
def find_length_validator
- find_validator(ActiveModel::Validations::LengthValidator)
+ find_validator(:length)
end
def has_tokenizer?(length_validator)
@@ -33,7 +33,7 @@ def maximum_value(validator_options)
end
def find_numericality_validator
- find_validator(ActiveModel::Validations::NumericalityValidator)
+ find_validator(:numericality)
end
def evaluate_numericality_validator_option(option)
@@ -19,7 +19,7 @@ def pattern_source
end
def find_pattern_validator
- find_validator(ActiveModel::Validations::FormatValidator)
+ find_validator(:format)
end
def evaluate_format_validator_option(option)
@@ -36,8 +36,8 @@ def action_validator_match?(validator)
end
end
- def find_validator(validator)
- attribute_validators.find { |v| validator === v } if has_validators?
+ def find_validator(kind)
+ attribute_validators.find { |v| v.kind == kind } if has_validators?
end
end
end

0 comments on commit 274d6ec

Please sign in to comment.