summaryrefslogtreecommitdiff
path: root/app/models/ci/variable.rb
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-01-14 14:23:42 +0100
committerRémy Coutable <remy@rymai.me>2016-01-14 14:23:42 +0100
commit1b08cd811abeed18c3601e1b997b0566a243662c (patch)
tree1b8f624b29bd2ae77d9344e31a3afe99f7b14536 /app/models/ci/variable.rb
parentc31d777c8f24029d7e11dd1e78eddf0c0b6e6f01 (diff)
parente47f0e563d127f593f16c0a521c836e21bceb77f (diff)
downloadgitlab-ce-1b08cd811abeed18c3601e1b997b0566a243662c.tar.gz
Merge branch 'master' of https://gitlab.com/gitlab-org/gitlab-ce into add-pagination-headers-to-api
Diffstat (limited to 'app/models/ci/variable.rb')
-rw-r--r--app/models/ci/variable.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/ci/variable.rb b/app/models/ci/variable.rb
index 7f6f497f325..e786bd7dd93 100644
--- a/app/models/ci/variable.rb
+++ b/app/models/ci/variable.rb
@@ -18,8 +18,12 @@ module Ci
belongs_to :project, class_name: '::Project', foreign_key: :gl_project_id
- validates_presence_of :key
validates_uniqueness_of :key, scope: :gl_project_id
+ validates :key,
+ presence: true,
+ length: { within: 0..255 },
+ format: { with: /\A[a-zA-Z0-9_]+\z/,
+ message: "can contain only letters, digits and '_'." }
attr_encrypted :value, mode: :per_attribute_iv_and_salt, key: Gitlab::Application.secrets.db_key_base
end