Skip to content

Commit

Permalink
Implementing JSON Schema validation (#71)
Browse files Browse the repository at this point in the history
* initial work on json schemas
* improve schema validation
- simplify schemas
- validate references for properties
- set up enum values for animationType (properties.json)
* complete properties.json schema
* code style for schema files
* Rework travis config to lint json and validate schema
* Add notes about `property-reference` validator extension
* PR review fixes and related
- rephrase comments
  • Loading branch information
lahmatiy authored and Elchi3 committed Jun 9, 2017
1 parent 8a3a82b commit d909960
Show file tree
Hide file tree
Showing 12 changed files with 605 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules/
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
language: node_js
before_script:
- npm install jsonlint -g
script:
- find . -name \*.json | xargs -I {} jsonlint -q {}
notifications:
email: false
sudo: false
script: "npm run travis"
103 changes: 103 additions & 0 deletions css/at-rules.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"definitions": {
"stringOrPropertyList": {
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"type": "string",
"property-reference": {
"comment": "property-reference is an extension to the JSON schema validator. Here it jumps 3 levels up in the hierarchy and tests if a value is an existing key in descriptors. See test/validate-schema.js for implementation details.",
"$data": "3"
}
}
}
]
}
},
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": false,
"properties": {
"syntax": {
"type": "string"
},
"interfaces": {
"type": "array",
"items": {
"type": "string"
}
},
"groups": {
"type": "array",
"items": {
"type": "string"
}
},
"descriptors": {
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": false,
"properties": {
"syntax": {
"type": "string"
},
"media": {
"type": "string"
},
"initial": {
"$ref": "#/definitions/stringOrPropertyList"
},
"percentages": {
"$ref": "#/definitions/stringOrPropertyList"
},
"computed": {
"$ref": "#/definitions/stringOrPropertyList"
},
"order": {
"enum": [
"orderOfAppearance",
"uniqueOrder"
]
},
"status": {
"enum": [
"standard",
"nonstandard",
"experimental"
]
}
},
"required": [
"syntax",
"media",
"initial",
"percentages",
"computed",
"order",
"status"
]
}
},
"status": {
"enum": [
"standard",
"nonstandard",
"experimental"
]
}
},
"required": [
"syntax",
"groups",
"status"
]
}
}
2 changes: 1 addition & 1 deletion css/properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -2581,7 +2581,7 @@
"media": "visual",
"inherited": false,
"animationType": "basicShapeOtherwiseNo",
"percentages": "referenceBoxWhenSpecifiedOtherwiseBorderBox",
"percentages": "referToReferenceBoxWhenSpecifiedOtherwiseBorderBox",
"groups": [
"CSS Miscellaneous"
],
Expand Down
Loading

0 comments on commit d909960

Please sign in to comment.