Sha256: 51571d4771ea663f6ebca19d33c6a4163a686a023bdf7fe4589e6edb638fd1ab
Contents?: true
Size: 551 Bytes
Versions: 12
Compression:
Stored size: 551 Bytes
Contents
# frozen_string_literal: true module Decidim module AttributeObject class NestedValidator < ActiveModel::EachValidator # :nodoc: def validate_each(record, attribute, value) value = value.values if value.is_a?(Hash) return unless Array(value).reject { |r| valid_object?(r) }.any? record.errors.add(attribute, :invalid, **options.merge(value: value)) end private def valid_object?(record) return true unless record.respond_to?(:valid?) record.valid? end end end end
Version data entries
12 entries across 12 versions & 1 rubygems