From cf7757efc3a53899f74aa2294f5ebf2c5828f080 Mon Sep 17 00:00:00 2001 From: Damion Dooley Date: Tue, 4 Oct 2022 07:34:50 -0700 Subject: [PATCH 1/2] fix to multi-select validation --- lib/DataHarmonizer.js | 3 +++ lib/utils/validation.js | 6 ++++-- package.json | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/DataHarmonizer.js b/lib/DataHarmonizer.js index 8edea6db..38a344cf 100644 --- a/lib/DataHarmonizer.js +++ b/lib/DataHarmonizer.js @@ -2122,6 +2122,7 @@ class DataHarmonizer { cellVal, field ); + valid = vocabValid; if (update) { this.hot.setDataAtCell(row, col, update, 'thisChange'); @@ -2138,6 +2139,8 @@ class DataHarmonizer { } // Hardcoded case: If field is xsd:token, and 1st picklist is // "null value menu" then ignore validation on free-text stuff. + // In other words, if picklist is only being provided for null + // values, then field must allow free text content. if ( !valid && field.datatype === 'xsd:token' && diff --git a/lib/utils/validation.js b/lib/utils/validation.js index 3322adaa..d8389f5e 100644 --- a/lib/utils/validation.js +++ b/lib/utils/validation.js @@ -100,14 +100,16 @@ export function validateValAgainstVocab(value, field) { export function validateValsAgainstVocab(delimited_string, field) { let update_flag = false; let value_array = delimited_string.split(';'); - value_array.forEach(function (value, index) { + // for-loop construct ensures return is out of this function. + for (let index = 0; index < value_array.length; index++) { + let value = value_array[index] const [valid, update] = validateValAgainstVocab(value, field); if (!valid) return [false, false]; if (update) { update_flag = true; value_array[index] = update; } - }); + } if (update_flag) return [true, value_array.join(';')]; else return [true, false]; } diff --git a/package.json b/package.json index 26237ad9..72b32bcb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "data-harmonizer", - "version": "1.4.2", + "version": "1.4.3", "description": "A standardized spreadsheet editor and validator that can be run offline and locally", "repository": "git@github.com:cidgoh/DataHarmonizer.git", "license": "MIT", From c02aefc58acf2fc49b687ef4ce1616bd8474433e Mon Sep 17 00:00:00 2001 From: Damion Dooley Date: Tue, 4 Oct 2022 07:37:36 -0700 Subject: [PATCH 2/2] Update validation.js --- lib/utils/validation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/validation.js b/lib/utils/validation.js index d8389f5e..623a5b9b 100644 --- a/lib/utils/validation.js +++ b/lib/utils/validation.js @@ -102,7 +102,7 @@ export function validateValsAgainstVocab(delimited_string, field) { let value_array = delimited_string.split(';'); // for-loop construct ensures return is out of this function. for (let index = 0; index < value_array.length; index++) { - let value = value_array[index] + let value = value_array[index]; const [valid, update] = validateValAgainstVocab(value, field); if (!valid) return [false, false]; if (update) {