class PatternValidator < ActiveModel::EachValidator
      TYPES = %w(regex)
      def validate_each(record, attribute, value)
        if TYPES.include?(record.type)
          record.errors.add(attribute, 'may not be blank') if value.blank?