class CategoriesArrayValidator < ActiveModel::EachValidator

  RUN_LIST_REGEX = /\A(role|recipe)\[[\w-]+(::[\w-]+)?\]\Z/

  def validate_each(record, attribute, valueArray)
    valueArray.each_with_index do |i, category|
      unless category.valid?
        category.errors.each do |key, value|
          record.errors.add "#{attribute}.#{i}.#{key}", value[0]
        end
      end
    end
  end

end
