Improve warnings in case of missing dependent column contents
This commit is contained in:
parent
f81089ac79
commit
f5ea1f850a
|
@ -102,6 +102,24 @@ class CsvxmlValidator {
|
|||
}
|
||||
}
|
||||
|
||||
let lineCounter = 1;
|
||||
for (let line of this.toValidate) {
|
||||
for (let fieldName in line) {
|
||||
|
||||
if (line[fieldName] === '') continue;
|
||||
|
||||
const dependencies = this.fieldList[fieldName].dependsOn;
|
||||
if (dependencies === undefined) continue;
|
||||
|
||||
for (let dependency of dependencies) {
|
||||
if (line[dependency] === '') {
|
||||
this.errors.dependentColumns.push("Dependency issue at column " + fieldName + ": Corresponding column " + dependency + " is empty");
|
||||
}
|
||||
}
|
||||
}
|
||||
lineCounter++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
checkControlledLists() {
|
||||
|
@ -115,7 +133,7 @@ class CsvxmlValidator {
|
|||
continue;
|
||||
}
|
||||
|
||||
let allowedValues = this.fieldList[fieldName].allowedValues;
|
||||
const allowedValues = this.fieldList[fieldName].allowedValues;
|
||||
|
||||
// No error if the field doesn't have a controlled list
|
||||
if (allowedValues === undefined || allowedValues === null) continue;
|
||||
|
@ -124,6 +142,7 @@ class CsvxmlValidator {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (line[fieldName] === '') continue;
|
||||
this.errors.controlledLists.push("Disallowed value used for column " + fieldName + " at line " + lineCounter + " (Allowed values are: " + Object.values(allowedValues).join(", ") + "; current value is " + line[fieldName] + ")");
|
||||
}
|
||||
lineCounter++;
|
||||
|
@ -385,7 +404,9 @@ class CsvxmlPage {
|
|||
if (field.allowedValues !== undefined) {
|
||||
// Join for object
|
||||
let values = [];
|
||||
for (let key in field.allowedValues) values.push(field.allowedValues[key]);
|
||||
for (let key in field.allowedValues) {
|
||||
values.push(field.allowedValues[key]);
|
||||
}
|
||||
line3.push(values.join(","));
|
||||
}
|
||||
else line3.push("");
|
||||
|
|
Loading…
Reference in New Issue
Block a user