Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Commit

Permalink
Add yaml validation for levels. (hedyorg#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
fpereiro authored Jun 4, 2021
1 parent 0892b12 commit 258378d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions build-tools/validate-yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ $scriptdir/node_modules/.bin/pajv validate \
--errors=text \
-s "adventures.schema.json" \
-d "*.yaml"

cd ../level-defaults/
$scriptdir/node_modules/.bin/pajv validate \
--errors=text \
-s "levels.schema.json" \
-d "*.yaml"
32 changes: 32 additions & 0 deletions coursedata/level-defaults/levels.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"title": "JSON Schema for Hedy Levels",
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^[0-9]{1,2}-?[0-9]{0,2}$": { "$ref": "#/definitions/Level" }
},
"definitions": {
"Level": {
"type": "object",
"properties": {
"intro_text": { "type": "string" },
"start_code": { "type": "string" },
"commands": {
"type": "array",
"additionalProperties": { "$ref": "#/definitions/Command" }
}
},
"required": ["intro_text", "start_code", "commands"],
"additionalProperties": false
},
"Command": {
"type": "object",
"properties": {
"explanation": { "type": "string" },
"example": { "type": "string" },
"demo_code": { "type": "string" }
},
"required": ["explanation", "example", "demo_code"]
}
}
}

0 comments on commit 258378d

Please sign in to comment.