From e635122ff6ef3f2c7b5ea458db078165d3832ebc Mon Sep 17 00:00:00 2001 From: Gabriel Jablonski Date: Tue, 25 Nov 2025 11:41:15 -0300 Subject: [PATCH] fix: add presence validation for account name (#12636) ## Description When a user tries creating a new account through the Super Admin dashboard, and they forget to fill in the account name, they're faced with an ugly error (generic "Something went wrong" on production). This PR simply adds the `validates :name, presence: true` model validation on `Account` model, which is translated as a proper error message on the Super Admin UI. --- app/models/account.rb | 1 + spec/models/account_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/app/models/account.rb b/app/models/account.rb index 7efb13bb5..06767939d 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -48,6 +48,7 @@ class Account < ApplicationRecord check_for_column: false }.freeze + validates :name, presence: true validates :domain, length: { maximum: 100 } validates_with JsonSchemaValidator, schema: SETTINGS_PARAMS_SCHEMA, diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 8504c6a04..0656870c8 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -22,6 +22,12 @@ RSpec.describe Account do describe 'length validations' do let(:account) { create(:account) } + it 'validates name presence' do + account.name = '' + account.valid? + expect(account.errors[:name]).to include("can't be blank") + end + it 'validates name length' do account.name = 'a' * 256 account.valid?