summaryrefslogtreecommitdiff
path: root/app/validators/namespace_name_validator.rb
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-12-07 16:17:24 -0500
committerRobert Speicher <rspeicher@gmail.com>2015-12-07 16:57:26 -0500
commit175f482c3cd584ba73c66e65aa180c1107e72913 (patch)
treed6a3e746fc564c9c18a3b928b1360f7ab529f3db /app/validators/namespace_name_validator.rb
parent9321d382bd5a0697e0e15a5065ec274e75541851 (diff)
downloadgitlab-ce-175f482c3cd584ba73c66e65aa180c1107e72913.tar.gz
Add custom NamespaceNameValidator
Diffstat (limited to 'app/validators/namespace_name_validator.rb')
-rw-r--r--app/validators/namespace_name_validator.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/validators/namespace_name_validator.rb b/app/validators/namespace_name_validator.rb
new file mode 100644
index 00000000000..2e51af2982d
--- /dev/null
+++ b/app/validators/namespace_name_validator.rb
@@ -0,0 +1,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