Class: Quby::TypeValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/active_model_modules/type_validator.rb

Overview

validates :key, ‘quby/type’: Symbol

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



3
4
5
6
7
# File 'lib/active_model_modules/type_validator.rb', line 3

def validate_each(record, attribute, value)
  return if value.is_a? options[:is_a]

  record.errors.add(attribute, "Is not of type #{options[:is_a]}")
end