Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
175f482c
Commit
175f482c
authored
Dec 07, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add custom NamespaceNameValidator
parent
9321d382
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
app/models/namespace.rb
app/models/namespace.rb
+3
-3
app/validators/namespace_name_validator.rb
app/validators/namespace_name_validator.rb
+10
-0
No files found.
app/models/namespace.rb
View file @
175f482c
...
@@ -23,10 +23,10 @@ class Namespace < ActiveRecord::Base
...
@@ -23,10 +23,10 @@ class Namespace < ActiveRecord::Base
validates
:owner
,
presence:
true
,
unless:
->
(
n
)
{
n
.
type
==
"Group"
}
validates
:owner
,
presence:
true
,
unless:
->
(
n
)
{
n
.
type
==
"Group"
}
validates
:name
,
validates
:name
,
presence:
true
,
uniqueness:
true
,
length:
{
within:
0
..
255
},
length:
{
within:
0
..
255
},
format:
{
with:
Gitlab
::
Regex
.
namespace_name_regex
,
namespace_name:
true
,
message:
Gitlab
::
Regex
.
namespace_name_regex_message
}
presence:
true
,
uniqueness:
true
validates
:description
,
length:
{
within:
0
..
255
}
validates
:description
,
length:
{
within:
0
..
255
}
validates
:path
,
validates
:path
,
...
...
app/validators/namespace_name_validator.rb
0 → 100644
View file @
175f482c
# 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment