Commit 17ea019f4e43b4fb394544f9d86ab3016f54d28e
1 parent
c4536ae5
Exists in
master
and in
4 other branches
Add Project name validation
Showing
2 changed files
with
7 additions
and
1 deletions
Show diff stats
app/models/project.rb
| ... | ... | @@ -64,7 +64,9 @@ class Project < ActiveRecord::Base |
| 64 | 64 | # Validations |
| 65 | 65 | validates :owner, presence: true |
| 66 | 66 | validates :description, length: { within: 0..2000 } |
| 67 | - validates :name, presence: true, length: { within: 0..255 } | |
| 67 | + validates :name, presence: true, length: { within: 0..255 }, | |
| 68 | + format: { with: Gitlab::Regex.project_name_regex, | |
| 69 | + message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } | |
| 68 | 70 | validates :path, presence: true, length: { within: 0..255 }, |
| 69 | 71 | format: { with: Gitlab::Regex.path_regex, |
| 70 | 72 | message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } | ... | ... |