Warn against invalid column headers being used, fail gracefully if ones
are present
This commit is contained in:
@ -44,6 +44,7 @@ class CsvxmlValidator {
|
||||
validate() {
|
||||
|
||||
this.validateMandatoryTagsPresent();
|
||||
this.validateInvalidTagsPresent();
|
||||
this.checkDuplicateInvNos();
|
||||
this.checkDependentColumns();
|
||||
this.checkControlledLists();
|
||||
@ -73,6 +74,18 @@ class CsvxmlValidator {
|
||||
|
||||
}
|
||||
|
||||
validateInvalidTagsPresent() {
|
||||
|
||||
const headers = Object.keys(this.toValidate[0]);
|
||||
|
||||
for (let header of headers) {
|
||||
if (this.fieldList[header] === undefined) {
|
||||
this.errors.parsing.push("Invalid column " + header + " detected! Please remove this column or use the appropriate name!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
checkDuplicateInvNos() {
|
||||
|
||||
let invNoEncountered = [];
|
||||
@ -107,6 +120,7 @@ class CsvxmlValidator {
|
||||
for (let fieldName in line) {
|
||||
|
||||
if (line[fieldName] === '') continue;
|
||||
if (this.fieldList[fieldName] === undefined) continue; // This may be the case if invalid fields are present
|
||||
|
||||
const dependencies = this.fieldList[fieldName].dependsOn;
|
||||
if (dependencies === undefined) continue;
|
||||
|
Reference in New Issue
Block a user