Class: MongoMapper::Plugins::Validations::AssociatedValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/mongo_mapper/plugins/validations.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



57
58
59
60
61
# File 'lib/mongo_mapper/plugins/validations.rb', line 57

def validate_each(record, attribute, value)
  if !Array.wrap(value).all? { |c| c.nil? || c.valid? }
    record.errors.add(attribute, :invalid, :default => options[:message], :value => value)
  end
end