summaryrefslogtreecommitdiff
path: root/app/validators/namespace_name_validator.rb
blob: 2e51af2982d59035420e458e50e073f27153e645 (plain)
1
2
3
4
5
6
7
8
9
10
# 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