diff options
-rw-r--r-- | app/models/account.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index 8891adb54..5c0f70ff8 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -54,13 +54,13 @@ class Account < ApplicationRecord validates :username, presence: true # Remote user validations - validates :username, uniqueness: { scope: :domain, case_sensitive: true }, if: -> { !local? && username_changed? } + validates :username, uniqueness: { scope: :domain, case_sensitive: true }, if: -> { !local? && will_save_change_to_username? } # Local user validations - validates :username, format: { with: /\A[a-z0-9_]+\z/i }, uniqueness: { scope: :domain, case_sensitive: false }, length: { maximum: 30 }, if: -> { local? && username_changed? } - validates_with UnreservedUsernameValidator, if: -> { local? && username_changed? } - validates :display_name, length: { maximum: 30 }, if: -> { local? && display_name_changed? } - validates :note, length: { maximum: 160 }, if: -> { local? && note_changed? } + validates :username, format: { with: /\A[a-z0-9_]+\z/i }, uniqueness: { scope: :domain, case_sensitive: false }, length: { maximum: 30 }, if: -> { local? && will_save_change_to_username? } + validates_with UnreservedUsernameValidator, if: -> { local? && will_save_change_to_username? } + validates :display_name, length: { maximum: 30 }, if: -> { local? && will_save_change_to_display_name? } + validates :note, length: { maximum: 160 }, if: -> { local? && will_save_change_to_note? } # Timelines has_many :stream_entries, inverse_of: :account, dependent: :destroy |