From 12082b91a3f434a9e8d51d38ebddd52cf0aa4bf2 Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Thu, 26 Jun 2025 23:47:38 +0200 Subject: [PATCH] Add validation messages for raw P1/11 lineNameInfo --- .../project-settings/input-raw-p111.vue | 59 ++++++++++++++++--- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/lib/www/client/source/src/components/project-settings/input-raw-p111.vue b/lib/www/client/source/src/components/project-settings/input-raw-p111.vue index 6474684..18ed0e5 100644 --- a/lib/www/client/source/src/components/project-settings/input-raw-p111.vue +++ b/lib/www/client/source/src/components/project-settings/input-raw-p111.vue @@ -7,6 +7,31 @@ :is-valid="isValid" :save="save" > + + + + + @@ -121,14 +146,34 @@ export default { }; }, + validationErrors () { + const errors = []; + + if (!this.cwo?.paths.length || !this.cwo?.paths[0].length) { + // "Missing path: we need at least one directory where to search for matching files" + errors.push("ERR_PATHS"); + } + + if (!this.cwo?.globs.length) { + // "Missing globs: we need at least one glob to search for matching files" + errors.push("ERR_GLOBS"); + } + + if (this.cwo?.lineNameInfo) { + const pass = !this.cwo?.lineNameInfo?.fields || [ "line", "sequence" ].every( i => + ["offset", "length"].every( j => j in (this.cwo?.lineNameInfo?.fields?.[i] ?? {}) )); + + if (!pass) { + // "Missing field info: We need at least 'line' and 'sequence' fields" + errors.push("ERR_LINEINFO") + } + } + + return errors; + }, + isValid () { - return !!(this.cwo?.paths.length && this.cwo?.globs.length && ( - this.cwo?.pattern?.regex && - ["direction", "line", "sequence"].every( i => this.cwo?.pattern?.captures?.includes(i) )) || ( - this.cwo?.lineNameInfo && - this.cwo?.lineNameInfo?.fields && - [ "line", "sequence", "incr" ].every( i => - ["offset", "length"].every( j => j in this.cwo?.lineNameInfo.fields[i] )))); + return this.validationErrors.length == 0; } },