Downgrade most item validations to be *not nil*, rather than present

Been running into the item "Hanging Plushie Grundo Background Item" not
being modelable, because TNT seem to have left its description blank!

Let's be less picky about what data we take in, but keep the intention
of these validations: to ensure that *we* don't make a mistake and
forget a field when importing items!
This commit is contained in:
Emi Matchu 2024-11-19 17:00:47 -08:00
parent e82c606ee8
commit 0261d02137

View file

@ -23,8 +23,13 @@ class Item < ApplicationRecord
has_many :dyeworks_variants, class_name: "Item", has_many :dyeworks_variants, class_name: "Item",
inverse_of: :dyeworks_base_item inverse_of: :dyeworks_base_item
validates_presence_of :name, :description, :thumbnail_url, :rarity, :price, # We require a name field. A number of other fields must be *specified*: they
:zones_restrict # can't be nil, to help ensure we aren't forgetting any fields when importing
# items. But sometimes they happen to be blank (e.g. when TNT leaves an item
# description empty, oops), in which case we want to accept that reality!
validates_presence_of :name
validates :description, :thumbnail_url, :rarity, :price, :zones_restrict,
exclusion: {in: [nil], message: "must be specified"}
attr_writer :current_body_id, :owned, :wanted attr_writer :current_body_id, :owned, :wanted