Added more info for when enums aren't matched

This commit is contained in:
PeekabooSteam 2023-12-28 14:10:51 +00:00
parent 955057183d
commit 82e60cd2cf
2 changed files with 56 additions and 2 deletions

View File

@ -367,7 +367,55 @@
}
},
"type": "object",
"required": ["activePath","alive","ammo","category","categoryDisplayName","coalition","contacts","controlled","country","desiredAltitude","desiredAltitudeType","desiredSpeed","desiredSpeedType","emissionsCountermeasures","followRoads","formationOffset","fuel","generalSettings","groupName","hasTask","heading","health","horizontalVelocity","human","ID","isActiveAWACS","isActiveTanker","isLeader","leaderID","name","onOff","operateAs","position","radio","reactionToThreat","ROE","shotsIntensity","shotsScatter","speed","state","TACAN","targetID","targetPosition","task","track","unitName","verticalVelocity"]
"required": [
"activePath",
"alive",
"ammo",
"category",
"categoryDisplayName",
"coalition",
"contacts",
"controlled",
"country",
"desiredAltitude",
"desiredAltitudeType",
"desiredSpeed",
"desiredSpeedType",
"emissionsCountermeasures",
"followRoads",
"formationOffset",
"fuel",
"generalSettings",
"groupName",
"hasTask",
"heading",
"health",
"horizontalVelocity",
"human",
"ID",
"isActiveAWACS",
"isActiveTanker",
"isLeader",
"leaderID",
"name",
"onOff",
"operateAs",
"position",
"radio",
"reactionToThreat",
"ROE",
"shotsIntensity",
"shotsScatter",
"speed",
"state",
"TACAN",
"targetID",
"targetPosition",
"task",
"track",
"unitName",
"verticalVelocity"
]
},
"minItems": 1,
"type": "array"

View File

@ -68,7 +68,13 @@ export class UnitDataFileImport extends UnitDataFile {
const validator = new ImportFileJSONSchemaValidator();
if (!validator.validate(this.#fileData)) {
const errors = validator.getErrors().reduce((acc:any, error:any) => {
acc.push(error.instancePath + ": " + error.message)
let errorString = error.instancePath.substring(1) + ": " + error.message;
if (error.params) {
const {allowedValues} = error.params;
if (allowedValues)
errorString += ": " + allowedValues.join(', ');
}
acc.push(errorString);
return acc;
}, [] as string[]);
this.#showFileDataErrors(errors);