Class: AllowedTypeValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/avromatic/model/allowed_type_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, name, value) ⇒ Object



2
3
4
5
6
# File 'lib/avromatic/model/allowed_type_validator.rb', line 2

def validate_each(record, name, value)
  if options[:in].find { |klass| value.is_a?(klass) }.nil?
    record.errors[name] << "does not have the expected type #{options[:in]}"
  end
end