Files
manyfold/app/validators/regex_array_validator.rb
James Smith 9e852a5c84 make sure regex array IS an array before validating it
This needs to be done because settings validators seems to pollute each other. I'll raise an issue for that, but in the meantime, this will do.
2026-05-14 14:58:57 +01:00

10 lines
287 B
Ruby

# frozen_string_literal: true
class RegexArrayValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
return unless value.is_a? Array
return unless value.any? { |pattern| pattern.to_regexp.nil? }
record.errors.add(attribute, :invalid)
end
end