Class: TypeValidator
- Inherits:
- 
      ActiveModel::EachValidator
      
        - Object
- ActiveModel::EachValidator
- TypeValidator
 
- Defined in:
- lib/type_validator.rb
Instance Method Summary collapse
Instance Method Details
#options ⇒ Object
| 4 5 6 | # File 'lib/type_validator.rb', line 4 def super.merge(allow_nil: true) end | 
#validate_each(record, attribute, value) ⇒ Object
| 8 9 10 11 12 13 | # File 'lib/type_validator.rb', line 8 def validate_each(record, attribute, value) classes = [:in] || [[:with]] if classes.all? { |klass| !value.is_a?(klass) } record.errors.add(attribute, "must be a #{classes.join(' or ')}, not a #{value.class}") end end |