Sha256: c1e967f41d6da5522d382e395698f48142484f43e88d61e300c8bc611a1cca70
Contents?: true
Size: 797 Bytes
Versions: 203
Compression:
Stored size: 797 Bytes
Contents
class ArrayValidator < ActiveModel::EachValidator def validate_each(record, attribute, values) Array(values).each do |value| options.each do |key, args| validator_options = {attributes: attribute} validator_options.merge!(args) if args.is_a?(Hash) next if value.nil? && validator_options[:allow_nil] next if value.blank? && validator_options[:allow_blank] validator_class_name = "#{key.to_s.camelize}Validator" validator_class = begin validator_class_name.constantize rescue NameError "ActiveModel::Validations::#{validator_class_name}".constantize end validator = validator_class.new(validator_options) validator.validate_each(record, attribute, value) end end end end
Version data entries
203 entries across 203 versions & 1 rubygems