Class: Codeclimate::Collectors::Validations::TypeValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Codeclimate::Collectors::Validations::TypeValidator
- Defined in:
- lib/codeclimate/collectors/validations/type_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attr_name, value) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/codeclimate/collectors/validations/type_validator.rb', line 5 def validate_each(record, attr_name, value) type = .fetch(:type) if !value.nil? && !value.is_a?(type) record.errors.add(attr_name, "must be a #{type}") end end |