summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFutseh <jonas.folvik@gmail.com>2019-02-22 19:07:34 +0100
committerFutseh <jonas.folvik@gmail.com>2019-02-22 19:07:34 +0100
commit1c9f62fb978ea2effb1389be5d56f29191baeedd (patch)
tree09520e6391873275091a16eb5432e59528fe78a5 /app
parentb3a347392331727d551d69a29175a50fe98e96a3 (diff)
Validates that the discord name is valid
Diffstat (limited to 'app')
-rw-r--r--app/models/user.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 6100f44..85c154e 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -18,9 +18,11 @@ class User < ActiveRecord::Base
validates_length_of :name, in: 2..30
validates_length_of :about, maximum: 5000
validates_length_of :ign, minimum: 1, maximum: 16
+ validates_length_of :discord, minimum: 2, maximum: 37 # The maximum length of a name is 32, but you need the # and four numbers
validates :email, uniqueness: {case_sensitive: false}, format: {with: /\A.+@(.+\..{2,}|\[(IPv6)?[0-9a-f:.]+\])\z/i, message: "That doesn't look like an email address."}
validates :ign, uniqueness: {case_sensitive: false}, format: {with: /\A[a-z\d_]+\z/i, message: "Username is invalid (a-z, 0-9, _)."}
+ validates :discord, uniqueness: {case_sensitive: false}, format: {with: /\A^(?!everyone|here|discordtag|.*```.*)([^@#:]{2,32}#[0-9]{4})$\z/i, message: "Discord name is invalid."}
validates :public_key, format: {with: /\A(-----BEGIN PGP PUBLIC KEY BLOCK-----((.|\n)*?)-----END PGP PUBLIC KEY BLOCK-----)?\z/i, message: "That doesn't look like a PGP formatted public key."}