Class: Ripple::Validations::AssociatedValidator

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

Instance Method Summary collapse

Methods included from Translation

#i18n_scope

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



7
8
9
10
# File 'lib/ripple/validations/associated_validator.rb', line 7

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, error_message_for(attribute, value))
end