Class: InstanceOfValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- InstanceOfValidator
- Defined in:
- lib/solid/validators/instance_of_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(model, attribute, value) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/solid/validators/instance_of_validator.rb', line 6 def validate_each(model, attribute, value) with_option = Array.wrap([:with] || [:in]) return if with_option.any? { |type| value.instance_of?(type) } = "is not an instance of #{with_option.map(&:name).join(" | ")}" Solid::Validators.add_error(model, attribute, , ) end |