Sha256: 5e81388a86b4be517eb231e38245de4bf8d57431bfbda42b7e57d4237f007c23
Contents?: true
Size: 501 Bytes
Versions: 25
Compression:
Stored size: 501 Bytes
Contents
require 'active_model' module Quby class ArrayAttributeValidValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) value&.each&.with_index do |element, index| if !element.respond_to?(:valid?) record.errors.add(attribute, "element ##{index} does not respond_to valid?") elsif !element.valid? record.errors.add(attribute, "element ##{index} #{element.errors.full_messages.join(', ')}") end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems