Skip to content

Commit

Permalink
Merge pull request #362 from cidgoh/multiselect-validation-fix
Browse files Browse the repository at this point in the history
fix to multi-select validation
  • Loading branch information
ddooley authored Oct 4, 2022
2 parents d35b75c + c02aefc commit 0ac1383
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/DataHarmonizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2122,6 +2122,7 @@ class DataHarmonizer {
cellVal,
field
);

valid = vocabValid;
if (update) {
this.hot.setDataAtCell(row, col, update, 'thisChange');
Expand All @@ -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' &&
Expand Down
6 changes: 4 additions & 2 deletions lib/utils/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 0ac1383

Please sign in to comment.