This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the validator | |
# app/validators/array_validator.rb | |
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) |