Added JSON Schema validation

This commit is contained in:
Felix Kirchner
2025-05-03 13:44:25 +02:00
parent 90cb7a3c2d
commit 12dfa821ea
3 changed files with 169 additions and 44 deletions

81
assets/schema.json Normal file
View File

@@ -0,0 +1,81 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Schema for cabo game data",
"type": "array",
"items": {
"type": "object",
"properties": {
"gameTitle": {
"type": "string"
},
"gameHasPointLimit": {
"type": "boolean"
},
"players": {
"type": "array",
"items": {
"type": "string"
}
},
"playerScores": {
"type": "array",
"items": {
"type": "number"
}
},
"roundNumber": {
"type": "number"
},
"isGameFinished": {
"type": "boolean"
},
"winner": {
"type": "string"
},
"roundList": {
"type": "array",
"items": {
"type": "object",
"properties": {
"roundNum": {
"type": "number"
},
"caboPlayerIndex": {
"type": "number"
},
"kamikazePlayerIndex": {},
"scores": {
"type": "array",
"items": {
"type": "number"
}
},
"scoreUpdates": {
"type": "array",
"items": {
"type": "number"
}
}
},
"required": [
"roundNum",
"caboPlayerIndex",
"kamikazePlayerIndex",
"scores",
"scoreUpdates"
]
}
}
},
"required": [
"gameTitle",
"gameHasPointLimit",
"players",
"playerScores",
"roundNumber",
"isGameFinished",
"winner",
"roundList"
]
}
}