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

Version Path
quby-compiler-0.5.0 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.4.16 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.4.15 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.4.14 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.4.13 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.4.12 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.4.11 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.4.10 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.4.9 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.4.8 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.4.7 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.4.6 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.4.5 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.4.4 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.4.3 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.4.2 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.4.1 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.4.0 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.3.7 lib/quby/array_attribute_valid_validator.rb
quby-compiler-0.3.6 lib/quby/array_attribute_valid_validator.rb