From ff9aec8702a0a7c8352dbb6b96acbc54a33d4634 Mon Sep 17 00:00:00 2001 From: znetsixe Date: Mon, 11 May 2026 15:21:13 +0200 Subject: [PATCH] P10.5: fix 4 pre-existing test failures (output + validation) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit outputUtils.formatMsg: fall back to \`_\` when config.general.name is unset — restores the convention the original test expected; safer for nodes whose name isn't required at registration. collectionValidators.validateArray + validateSet: replace \`|| 1\` with \`?? 1\` so explicit minLength: 0 lets through empty arrays. Was swallowing the 0 as falsy and clamping minimum to 1. validationUtils: add public validateCurve wrapper around the helper so callers can validate raw curves without going through validateSchema. Test suite: 170 total / 170 pass (was 4 fail). Co-Authored-By: Claude Opus 4.7 (1M context) --- src/helper/outputUtils.js | 5 ++++- src/helper/validationUtils.js | 7 +++++++ src/helper/validators/collectionValidators.js | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/helper/outputUtils.js b/src/helper/outputUtils.js index bf29b36..bf24246 100644 --- a/src/helper/outputUtils.js +++ b/src/helper/outputUtils.js @@ -37,7 +37,10 @@ class OutputUtils { const changedFields = this.checkForChanges(output,format); if (Object.keys(changedFields).length > 0) { - const measurement = config.general.name; + // Fall back to `_` when `general.name` is unset — + // the original convention before name became a registered config field. + const measurement = config.general.name + || `${config.functionality?.softwareType}_${config.general.id}`; const flatTags = this.flattenTags(this.extractRelevantConfig(config)); const formatterName = this.resolveFormatterName(config, format); const formatter = getFormatter(formatterName); diff --git a/src/helper/validationUtils.js b/src/helper/validationUtils.js index 8e1111c..f65e510 100644 --- a/src/helper/validationUtils.js +++ b/src/helper/validationUtils.js @@ -233,6 +233,13 @@ class ValidationUtils { return fieldSchema.default; } } + + // Public wrapper for the curve validator — exposes the helper so + // callers (and tests) can validate a raw curve without going + // through validateSchema. + validateCurve(input, defaultCurve) { + return validateCurve(input, defaultCurve, this.logger); + } } module.exports = ValidationUtils; diff --git a/src/helper/validators/collectionValidators.js b/src/helper/validators/collectionValidators.js index 14e4794..8495ec5 100644 --- a/src/helper/validators/collectionValidators.js +++ b/src/helper/validators/collectionValidators.js @@ -17,7 +17,7 @@ function validateArray(configValue, rules, fieldSchema, name, key, logger) { } }) .slice(0, rules.maxLength || Infinity); - if (validatedArray.length < (rules.minLength || 1)) { + if (validatedArray.length < (rules.minLength ?? 1)) { logger.warn( `${name}.${key} contains fewer items than allowed (${rules.minLength}). Using default value.` ); @@ -41,7 +41,7 @@ function validateSet(configValue, rules, fieldSchema, name, key, logger) { } }) .slice(0, rules.maxLength || Infinity); - if (validatedArray.length < (rules.minLength || 1)) { + if (validatedArray.length < (rules.minLength ?? 1)) { logger.warn( `${name}.${key} contains fewer items than allowed (${rules.minLength}). Using default value.` );