diff options
Diffstat (limited to 'app/models/projects/topic.rb')
-rw-r--r-- | app/models/projects/topic.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/projects/topic.rb b/app/models/projects/topic.rb index 347d65841ed..a3622150351 100644 --- a/app/models/projects/topic.rb +++ b/app/models/projects/topic.rb @@ -7,9 +7,18 @@ module Projects include Avatarable include Gitlab::SQL::Pattern + SLUG_ALLOWED_REGEX = %r{\A[a-zA-Z0-9_\-.]+\z} + validates :name, presence: true, length: { maximum: 255 } validates :name, uniqueness: { case_sensitive: false }, if: :name_changed? validate :validate_name_format, if: :name_changed? + + validates :slug, + length: { maximum: 255 }, + uniqueness: { case_sensitive: false }, + format: { with: SLUG_ALLOWED_REGEX, message: "can contain only letters, digits, '_', '-', '.'" }, + if: :slug_changed? + validates :title, presence: true, length: { maximum: 255 }, on: :create validates :description, length: { maximum: 1024 } |