Class: Telephone::TypeValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Telephone::TypeValidator
- Defined in:
- lib/telephone/validators/type_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/telephone/validators/type_validator.rb', line 7 def validate_each(record, attribute, value) expected_type = [:with] return if value.is_a?(expected_type) record.errors.add( attribute, :invalid_type, **.except(:with).merge(type: type_name(expected_type)) ) end |