Class: Ripple::Validations::AssociatedValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
ripple/lib/ripple/validations/associated_validator.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) validate_each(record, attribute, value)



22
23
24
25
# File 'ripple/lib/ripple/validations/associated_validator.rb', line 22

def validate_each(record, attribute, value)
  return if (value.is_a?(Array) ? value : [value]).collect{ |r| r.nil? || r.valid? }.all?
  record.errors.add(attribute, :invalid, options.merge(:value => value))
end