A warning, what the current value is, is now displayed if a disallowed

value is entered

Close #21
This commit is contained in:
Joshua Ramon Enslin 2022-11-10 07:52:52 +01:00
parent 952c0b9b1f
commit 8de7ec1809
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
4 changed files with 6 additions and 6 deletions

View File

@ -170,7 +170,7 @@ class CsvxmlValidator {
continue;
}
this.errors.controlledLists.push("Disallowed value used for column " + fieldName + " at line " + lineCounter + " (Allowed values are: " + Object.values(allowedValues).join(", ") + ")");
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++;
}

View File

@ -17,7 +17,7 @@ invNoEncountered.push(line.inventory_number);lineCounter++;}}
checkDependentColumns(){const headers=Object.keys(this.toValidate[0]);for(let header of headers){if(this.fieldList[header]===undefined||this.fieldList[header].dependsOn===undefined||this.fieldList[header].dependsOn===null)continue;let dependencies=this.fieldList[header].dependsOn;for(let dep of dependencies){if(headers.includes(dep)===false){this.errors.dependentColumns.push("Dependency issue at column "+header+": Corresponding column "+dep+" is missing");}}}}
checkControlledLists(){let lineCounter=1;for(let line of this.toValidate){for(let fieldName in line){if(this.fieldList[fieldName]===undefined){console.log("Undefined but requested field "+fieldName);continue;}
let allowedValues=this.fieldList[fieldName].allowedValues;if(allowedValues===undefined||allowedValues===null)continue;if(Object.values(allowedValues).length===0||Object.values(allowedValues).includes(line[fieldName])){continue;}
this.errors.controlledLists.push("Disallowed value used for column "+fieldName+" at line "+lineCounter+" (Allowed values are: "+Object.values(allowedValues).join(", ")+")");}
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++;}}
checkMainImageResource(){}
isValid(){for(let errorClass in this.errors){if(this.errors[errorClass].length!==0)return false;}

View File

@ -4,7 +4,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="assets/css/csvxml.min.css?v000001" />
<link rel="stylesheet" type="text/css" href="assets/css/csvxml.min.css?v000002" />
<link rel="manifest" href="/manifest.json" />
<meta name="theme-color" content="#aa4400" />
@ -27,7 +27,7 @@
</head>
<body class="loading">
<script src="assets/js/csvxmlV2.min.js?v000001" type="text/javascript" async></script>
<script src="assets/js/csvxmlV2.min.js?v000002" type="text/javascript" async></script>
</body>
</html>

View File

@ -76,7 +76,7 @@ function generateAppShell():string {
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="assets/css/csvxml.min.css?v000001" />
<link rel="stylesheet" type="text/css" href="assets/css/csvxml.min.css?v000002" />
<link rel="manifest" href="/manifest.json" />
<meta name="theme-color" content="#aa4400" />
@ -99,7 +99,7 @@ function generateAppShell():string {
</head>
<body class="loading">
<script src="assets/js/csvxmlV2.min.js?v000001" type="text/javascript" async></script>
<script src="assets/js/csvxmlV2.min.js?v000002" type="text/javascript" async></script>
</body>
</html>';