mirror of https://github.com/mastodon/mastodon
Extract `DISPLAY_NAME_LENGTH_LIMIT` constant in `Account` class
This commit is contained in:
parent
024d2ba10d
commit
827a2ab800
|
@ -72,6 +72,7 @@ class Account < ApplicationRecord
|
||||||
URL_PREFIX_RE = %r{\Ahttp(s?)://[^/]+}
|
URL_PREFIX_RE = %r{\Ahttp(s?)://[^/]+}
|
||||||
USERNAME_ONLY_RE = /\A#{USERNAME_RE}\z/i
|
USERNAME_ONLY_RE = /\A#{USERNAME_RE}\z/i
|
||||||
USERNAME_LENGTH_LIMIT = 30
|
USERNAME_LENGTH_LIMIT = 30
|
||||||
|
DISPLAY_NAME_LENGTH_LIMIT = 30
|
||||||
|
|
||||||
include Attachmentable # Load prior to Avatar & Header concerns
|
include Attachmentable # Load prior to Avatar & Header concerns
|
||||||
|
|
||||||
|
@ -103,7 +104,7 @@ class Account < ApplicationRecord
|
||||||
# Local user validations
|
# Local user validations
|
||||||
validates :username, format: { with: /\A[a-z0-9_]+\z/i }, length: { maximum: USERNAME_LENGTH_LIMIT }, if: -> { local? && will_save_change_to_username? && actor_type != 'Application' }
|
validates :username, format: { with: /\A[a-z0-9_]+\z/i }, length: { maximum: USERNAME_LENGTH_LIMIT }, if: -> { local? && will_save_change_to_username? && actor_type != 'Application' }
|
||||||
validates_with UnreservedUsernameValidator, if: -> { local? && will_save_change_to_username? && actor_type != 'Application' }
|
validates_with UnreservedUsernameValidator, if: -> { local? && will_save_change_to_username? && actor_type != 'Application' }
|
||||||
validates :display_name, length: { maximum: 30 }, if: -> { local? && will_save_change_to_display_name? }
|
validates :display_name, length: { maximum: DISPLAY_NAME_LENGTH_LIMIT }, if: -> { local? && will_save_change_to_display_name? }
|
||||||
validates :note, note_length: { maximum: 500 }, if: -> { local? && will_save_change_to_note? }
|
validates :note, note_length: { maximum: 500 }, if: -> { local? && will_save_change_to_note? }
|
||||||
validates :fields, length: { maximum: DEFAULT_FIELDS_SIZE }, if: -> { local? && will_save_change_to_fields? }
|
validates :fields, length: { maximum: DEFAULT_FIELDS_SIZE }, if: -> { local? && will_save_change_to_fields? }
|
||||||
validates :uri, absence: true, if: :local?, on: :create
|
validates :uri, absence: true, if: :local?, on: :create
|
||||||
|
|
Loading…
Reference in New Issue