From 5b995143f1ba3278e799e46b76646a9878977677 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 10 Sep 2024 04:03:45 -0400 Subject: [PATCH] Use `with_options` for shared Account validation option value (#31827) --- app/models/account.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/account.rb b/app/models/account.rb index d773d33441..4a7c752e7c 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -111,10 +111,12 @@ class Account < ApplicationRecord validates :display_name, length: { maximum: DISPLAY_NAME_LENGTH_LIMIT }, if: -> { local? && will_save_change_to_display_name? } validates :note, note_length: { maximum: NOTE_LENGTH_LIMIT }, if: -> { local? && will_save_change_to_note? } validates :fields, length: { maximum: DEFAULT_FIELDS_SIZE }, if: -> { local? && will_save_change_to_fields? } - validates :uri, absence: true, if: :local?, on: :create - validates :inbox_url, absence: true, if: :local?, on: :create - validates :shared_inbox_url, absence: true, if: :local?, on: :create - validates :followers_url, absence: true, if: :local?, on: :create + with_options on: :create do + validates :uri, absence: true, if: :local? + validates :inbox_url, absence: true, if: :local? + validates :shared_inbox_url, absence: true, if: :local? + validates :followers_url, absence: true, if: :local? + end normalizes :username, with: ->(username) { username.squish }