Revision 4a96211d
Added by Shira Maximov over 6 years ago
app/models/ssh_key.rb | ||
---|---|---|
validates :key,
|
||
:presence => true,
|
||
:ssh_key => true,
|
||
:format => { with: /\A(ssh|ecdsa)-.*\Z/ }
|
||
:format => { with: /\A(ssh|ecdsa)-.*\Z/, message: N_('must be in OpenSSH public key format') }
|
||
|
||
validates :key,
|
||
:format => { :without => /\n|\r/, :message => N_('should be a single line') }
|
app/validators/ssh_key_validator.rb | ||
---|---|---|
class SshKeyValidator < ActiveModel::EachValidator
|
||
def validate_each(record, attribute, value)
|
||
if value && !valid_ssh_public_key?(value)
|
||
record.errors[attribute] << _('is invalid')
|
||
record.errors[attribute] << _('is not a valid public ssh key')
|
||
end
|
||
end
|
||
|
Also available in: Unified diff
Fixes #20890 - changes SSH key validation messages