Skip to content

Commit

Permalink
Add option to also validate the schema
Browse files Browse the repository at this point in the history
  • Loading branch information
erayd committed Mar 3, 2017
1 parent cd1ca02 commit a41f62b
Show file tree
Hide file tree
Showing 44 changed files with 830 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ third argument to `Validator::validate()`, or can be provided as the third argum
| `Constraint::CHECK_MODE_COERCE_TYPES` | Convert data types to match the schema where possible |
| `Constraint::CHECK_MODE_APPLY_DEFAULTS` | Apply default values from the schema if not set |
| `Constraint::CHECK_MODE_EXCEPTIONS` | Throw an exception immediately if validation fails |
| `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 a41f62b

Please sign in to comment.