Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix to multi-select validation #362

Merged
merged 2 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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