Add Project name validation

This commit is contained in:
Andrey Kumanyaev 2012-12-26 02:50:41 +04:00
parent c4536ae587
commit 17ea019f4e
2 changed files with 7 additions and 1 deletions

View file

@ -64,7 +64,9 @@ class Project < ActiveRecord::Base
# Validations # Validations
validates :owner, presence: true validates :owner, presence: true
validates :description, length: { within: 0..2000 } validates :description, length: { within: 0..2000 }
validates :name, presence: true, length: { within: 0..255 } validates :name, presence: true, length: { within: 0..255 },
format: { with: Gitlab::Regex.project_name_regex,
message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" }
validates :path, presence: true, length: { within: 0..255 }, validates :path, presence: true, length: { within: 0..255 },
format: { with: Gitlab::Regex.path_regex, format: { with: Gitlab::Regex.path_regex,
message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" }

View file

@ -6,6 +6,10 @@ module Gitlab
default_regex default_regex
end end
def project_name_regex
default_regex
end
def path_regex def path_regex
default_regex default_regex
end end