summaryrefslogtreecommitdiff
path: root/app/validators/namespace_name_validator.rb
blob: fb1c241037ceeb203edffae120c3591d7e4bea72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
# frozen_string_literal: true

# NamespaceNameValidator
#
# Custom validator for GitLab namespace name strings.
class NamespaceNameValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    unless value =~ Gitlab::Regex.namespace_name_regex
      record.errors.add(attribute, Gitlab::Regex.namespace_name_regex_message)
    end
  end
end