Sha256: 5b99384f46fa7cfd001d5010e785c2436c7db52e9e8d0ed13b7458c9caf2f8b4
Contents?: true
Size: 388 Bytes
Versions: 12
Compression:
Stored size: 388 Bytes
Contents
module HashieModel class AssociatedValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return if (value.is_a?(Array) ? value : [value]).collect{ |r| r.nil? || r.valid? }.all? errors = value.is_a?(Array) ? value.map(&:errors).first : value.errors record.errors.add(attribute, errors, options.merge(:value => value)) end end end
Version data entries
12 entries across 12 versions & 1 rubygems