Class: KindValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/kind/validator.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object

Raises:



48
49
50
51
52
53
54
55
56
# File 'lib/kind/validator.rb', line 48

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

  return unless error = call_validation_for(attribute, value)

  raise Kind::Error.new("#{attribute} #{error}") if options[:strict]

  record.errors.add(attribute, error)
end