Class: Braspag::Order::AssociationValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/cbraspag/core/order.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



34
35
36
37
38
# File 'lib/cbraspag/core/order.rb', line 34

def validate_each(record, attribute, value)
  unless value.respond_to?(:valid?) && value.try(:valid?, self.options[:on])
    record.errors.add attribute, "invalid data"
  end
end