diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-12-07 16:17:24 -0500 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-12-07 16:57:26 -0500 |
commit | 175f482c3cd584ba73c66e65aa180c1107e72913 (patch) | |
tree | d6a3e746fc564c9c18a3b928b1360f7ab529f3db /app/validators | |
parent | 9321d382bd5a0697e0e15a5065ec274e75541851 (diff) | |
download | gitlab-ce-175f482c3cd584ba73c66e65aa180c1107e72913.tar.gz |
Add custom NamespaceNameValidator
Diffstat (limited to 'app/validators')
-rw-r--r-- | app/validators/namespace_name_validator.rb | 10 |
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 |