Skip to content

Commit

Permalink
Add option to also validate the schema (jsonrainbow#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
erayd committed Mar 22, 2017
1 parent ce1988f commit b5bc719
Show file tree
Hide file tree
Showing 45 changed files with 836 additions and 19 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ third argument to `Validator::validate()`, or can be provided as the third argum
| `Constraint::CHECK_MODE_ONLY_REQUIRED_DEFAULTS` | When applying defaults, only set values that are required |
| `Constraint::CHECK_MODE_EXCEPTIONS` | Throw an exception immediately if validation fails |
| `Constraint::CHECK_MODE_DISABLE_FORMAT` | Do not validate "format" constraints |
| `Constraint::CHECK_MODE_VALIDATE_SCHEMA` | Validate the schema as well as the provided document |

Please note that using `Constraint::CHECK_MODE_COERCE_TYPES` or `Constraint::CHECK_MODE_APPLY_DEFAULTS`
will modify your original data.
Expand Down
193 changes: 193 additions & 0 deletions schema-validation/json-schema-draft-03.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
{
"$schema": "http://json-schema.org/draft-03/schema#",
"id": "http://json-schema.org/draft-03/schema#",
"type": "object",
"properties": {
"type": {
"type": [
"string",
"array"
],
"items": {
"type": [
"string",
{
"$ref": "#"
}
]
},
"uniqueItems": true,
"default": "any"
},
"properties": {
"type": "object",
"additionalProperties": {
"$ref": "#"
},
"default": {}
},
"patternProperties": {
"type": "object",
"additionalProperties": {
"$ref": "#"
},
"default": {}
},
"additionalProperties": {
"type": [
{
"$ref": "#"
},
"boolean"
],
"default": {}
},
"items": {
"type": [
{
"$ref": "#"
},
"array"
],
"items": {
"$ref": "#"
},
"default": {}
},
"additionalItems": {
"type": [
{
"$ref": "#"
},
"boolean"
],
"default": {}
},
"required": {
"type": "boolean",
"default": false
},
"dependencies": {
"type": "object",
"additionalProperties": {
"type": [
"string",
"array",
{
"$ref": "#"
}
],
"items": {
"type": "string"
}
},
"default": {}
},
"minimum": {
"type": "number"
},
"maximum": {
"type": "number"
},
"exclusiveMinimum": {
"type": "boolean",
"default": false
},
"exclusiveMaximum": {
"type": "boolean",
"default": false
},
"minItems": {
"type": "integer",
"minimum": 0,
"default": 0
},
"maxItems": {
"type": "integer",
"minimum": 0
},
"uniqueItems": {
"type": "boolean",
"default": false
},
"pattern": {
"type": "string",
"format": "regex"
},
"minLength": {
"type": "integer",
"minimum": 0,
"default": 0
},
"maxLength": {
"type": "integer"
},
"enum": {
"type": "array",
"minItems": 1,
"uniqueItems": true
},
"default": {
"type": "any"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"format": {
"type": "string"
},
"divisibleBy": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": true,
"default": 1
},
"disallow": {
"type": [
"string",
"array"
],
"items": {
"type": [
"string",
{
"$ref": "#"
}
]
},
"uniqueItems": true
},
"extends": {
"type": [
{
"$ref": "#"
},
"array"
],
"items": {
"$ref": "#"
},
"default": {}
},
"id": {
"type": "string",
"format": "uri"
},
"$ref": {
"type": "string",
"format": "uri"
},
"$schema": {
"type": "string",
"format": "uri"
}
},
"dependencies": {
"exclusiveMinimum": "minimum",
"exclusiveMaximum": "maximum"
},
"default": {}
}
Loading

0 comments on commit b5bc719

Please sign in to comment.