From d2599d0db3147844f94bea0d41d6522428f6046d Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 25 Apr 2026 19:39:25 -0600 Subject: [PATCH] Make it so preUpdate hooks can't violate my data model constraints --- module/data/Item/attribute.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/module/data/Item/attribute.mjs b/module/data/Item/attribute.mjs index 8e38272..6d87fb2 100644 --- a/module/data/Item/attribute.mjs +++ b/module/data/Item/attribute.mjs @@ -72,6 +72,9 @@ export class AttributeItemData extends foundry.abstract.TypeDataModel { }; async _preUpdate(data, options, user) { + const allowed = await super._preUpdate(data, options, user); + if (allowed === false) { return false }; + // Prevent invalid IDs if (hasProperty(data, `system.key`) && !isValidID(data.system.key)) { ui.notifications.error(_loc( @@ -91,8 +94,6 @@ export class AttributeItemData extends foundry.abstract.TypeDataModel { setProperty(data, `system.value`, clamp(min, value, max)); }; - - return super._preUpdate(data, options, user); }; // #endregion Lifecycle