diff options
author | Rémy Coutable <remy@rymai.me> | 2016-12-02 13:54:57 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-12-06 10:23:17 +0100 |
commit | 4e249d5baea99a52915025fc2827d01ab2d77c18 (patch) | |
tree | 98a0eaa592fdb17657e10a6cd9fe941b17c0253d /app/models/key.rb | |
parent | 90c0f610e29976608dbfeeb63bc4763982c5dbc3 (diff) | |
download | gitlab-ce-4e249d5baea99a52915025fc2827d01ab2d77c18.tar.gz |
Use :maximum instead of :within for length validators with a 0..N range25209-improve-length-validators
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/models/key.rb')
-rw-r--r-- | app/models/key.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/app/models/key.rb b/app/models/key.rb index ff8dda2dc89..a5d25409730 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -8,10 +8,18 @@ class Key < ActiveRecord::Base before_validation :generate_fingerprint - validates :title, presence: true, length: { within: 0..255 } - validates :key, presence: true, length: { within: 0..5000 }, format: { with: /\A(ssh|ecdsa)-.*\Z/ } - validates :key, format: { without: /\n|\r/, message: 'should be a single line' } - validates :fingerprint, uniqueness: true, presence: { message: 'cannot be generated' } + validates :title, + presence: true, + length: { maximum: 255 } + validates :key, + presence: true, + length: { maximum: 5000 }, + format: { with: /\A(ssh|ecdsa)-.*\Z/ } + validates :key, + format: { without: /\n|\r/, message: 'should be a single line' } + validates :fingerprint, + uniqueness: true, + presence: { message: 'cannot be generated' } delegate :name, :email, to: :user, prefix: true |