0
0
Fork 0

Added validator for extra profile field values with empty name (#33421)

This commit is contained in:
Tim Rogers 2025-01-04 13:42:27 -06:00 committed by GitHub
parent 9b82bedc6f
commit 3bdfa3eb4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 35 additions and 1 deletions

View file

@ -118,6 +118,7 @@ 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_with EmptyProfileFieldNamesValidator, if: -> { local? && will_save_change_to_fields? }
with_options on: :create do
validates :uri, absence: true, if: :local?
validates :inbox_url, absence: true, if: :local?
@ -300,7 +301,7 @@ class Account < ApplicationRecord
if attributes.is_a?(Hash)
attributes.each_value do |attr|
next if attr[:name].blank?
next if attr[:name].blank? && attr[:value].blank?
previous = old_fields.find { |item| item['value'] == attr[:value] }