diff --git a/src/js/datatypeCleanupJS.js b/src/js/datatypeCleanupJS.js index a55b7e5c6841272e130baaf45591f9c87f99c6e5..4dd22853b89cad2cd1d0336520ed0b95b90b1fb8 100644 --- a/src/js/datatypeCleanupJS.js +++ b/src/js/datatypeCleanupJS.js @@ -2146,3 +2146,29 @@ App.Entity.Utils.RARuleDatatypeCleanup = function() { set.growth.intensity = Math.clamp(+set.growth.intensity, 0, 1) || 0; } }(); + +App.Entity.Utils.validateRules = function() { + /** @type {App.RA.Rule[]} */ + const rules = State.variables.defaultRules; + + function testObject(o, path) { + for (const p in o) { + const v = o[p]; + if (v === undefined) { + throw `Property ${path}.${p} is undefined`; + } + if (v !== null && typeof v === 'object') { + testObject(v, path + '.' + p); + } + } + } + + /** @type {App.RA.Rule} */ + for (const rule of rules) { + try { + testObject(rule.set, "set"); + } catch (e) { + console.error(`Error in rule ${rule.name}: ${e}`); + } + } +};