Sha256: cff07d00c3c6d4c4705fb3ddfe90a30486303db17401456621d049a622443914
Contents?: true
Size: 440 Bytes
Versions: 4
Compression:
Stored size: 440 Bytes
Contents
module HashieModel class AssociatedValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) collection = value.is_a?(Array) ? value : [value] invalid_elements = collection.select { |e| e && !e.valid? } if invalid_elements.present? first_error = invalid_elements.first.errors record.errors.add(attribute, first_error, options.merge(value: value)) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems