From 4e5bb350d17854e8d0356ea5d515defebef7cbf9 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Fri, 19 Sep 2025 23:36:04 -0700 Subject: [PATCH] Make transcendence_step optional in grid models - Change transcendence_step validation from required to optional - Allow nil values but maintain numeric validation when present - Add nil check in GridCharacter transcendence validation --- app/models/grid_character.rb | 5 +++-- app/models/grid_summon.rb | 4 ++-- app/models/grid_weapon.rb | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/models/grid_character.rb b/app/models/grid_character.rb index 98e5e80..58499ec 100644 --- a/app/models/grid_character.rb +++ b/app/models/grid_character.rb @@ -27,9 +27,9 @@ class GridCharacter < ApplicationRecord # Validations validates_presence_of :party - # Validate that uncap_level and transcendence_step are present and numeric. + # Validate that uncap_level is present and numeric, transcendence_step is optional but must be numeric if present. validates :uncap_level, presence: true, numericality: { only_integer: true } - validates :transcendence_step, presence: true, numericality: { only_integer: true } + validates :transcendence_step, numericality: { only_integer: true }, allow_nil: true validate :validate_awakening_level, on: :update validate :transcendence, on: :update @@ -77,6 +77,7 @@ class GridCharacter < ApplicationRecord # @note Triggered on update. # @return [void] def transcendence + return if transcendence_step.nil? errors.add(:transcendence_step, 'character has no transcendence') if transcendence_step.positive? && !character.ulb errors.add(:transcendence_step, 'transcendence step too high') if transcendence_step > 5 && character.ulb errors.add(:transcendence_step, 'transcendence step too low') if transcendence_step.negative? && character.ulb diff --git a/app/models/grid_summon.rb b/app/models/grid_summon.rb index 6bb2e8f..16811b2 100644 --- a/app/models/grid_summon.rb +++ b/app/models/grid_summon.rb @@ -22,9 +22,9 @@ class GridSummon < ApplicationRecord validates :position, presence: true validate :compatible_with_position, on: :create - # Validate that uncap_level and transcendence_step are present and numeric. + # Validate that uncap_level is present and numeric, transcendence_step is optional but must be numeric if present. validates :uncap_level, presence: true, numericality: { only_integer: true } - validates :transcendence_step, presence: true, numericality: { only_integer: true } + validates :transcendence_step, numericality: { only_integer: true }, allow_nil: true # Custom validation to enforce maximum uncap_level based on the associated Summon’s flags. validate :validate_uncap_level_based_on_summon_flags diff --git a/app/models/grid_weapon.rb b/app/models/grid_weapon.rb index a618dda..beb05e5 100644 --- a/app/models/grid_weapon.rb +++ b/app/models/grid_weapon.rb @@ -39,9 +39,9 @@ class GridWeapon < ApplicationRecord belongs_to :awakening, optional: true - # Validate that uncap_level and transcendence_step are present and numeric. + # Validate that uncap_level is present and numeric, transcendence_step is optional but must be numeric if present. validates :uncap_level, presence: true, numericality: { only_integer: true } - validates :transcendence_step, presence: true, numericality: { only_integer: true } + validates :transcendence_step, numericality: { only_integer: true }, allow_nil: true validate :compatible_with_position, on: :create validate :no_conflicts, on: :create