gitlab-org--gitlab-foss/app/validators/namespace_name_validator.rb
2018-06-27 09:48:37 -07:00

12 lines
368 B
Ruby

# 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