Squashed 'json/' content from commit 29e2c7c
git-subtree-dir: json git-subtree-split: 29e2c7c241f1d508d584b412ba8fccd6c25e7f14
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
TODO
 | 
			
		||||
							
								
								
									
										4
									
								
								.travis.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								.travis.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
language: python
 | 
			
		||||
python: "2.7"
 | 
			
		||||
install: pip install jsonschema
 | 
			
		||||
script: bin/jsonschema_suite check
 | 
			
		||||
							
								
								
									
										19
									
								
								LICENSE
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								LICENSE
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
Copyright (c) 2012 Julian Berman
 | 
			
		||||
 | 
			
		||||
Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
in the Software without restriction, including without limitation the rights
 | 
			
		||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
furnished to do so, subject to the following conditions:
 | 
			
		||||
 | 
			
		||||
The above copyright notice and this permission notice shall be included in
 | 
			
		||||
all copies or substantial portions of the Software.
 | 
			
		||||
 | 
			
		||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
THE SOFTWARE.
 | 
			
		||||
							
								
								
									
										78
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,78 @@
 | 
			
		||||
JSON Schema Test Suite [](https://travis-ci.org/json-schema/JSON-Schema-Test-Suite)
 | 
			
		||||
======================
 | 
			
		||||
 | 
			
		||||
This repository contains a set of JSON objects that implementors of JSON Schema
 | 
			
		||||
validation libraries can use to test their validators.
 | 
			
		||||
 | 
			
		||||
It is meant to be language agnostic and should require only a JSON parser.
 | 
			
		||||
 | 
			
		||||
The conversion of the JSON objects into tests within your test framework of
 | 
			
		||||
choice is still the job of the validator implementor.
 | 
			
		||||
 | 
			
		||||
Structure of a Test
 | 
			
		||||
-------------------
 | 
			
		||||
 | 
			
		||||
If you're going to use this suite, you need to know how tests are laid out. The
 | 
			
		||||
tests are contained in the `tests` directory at the root of this repository.
 | 
			
		||||
 | 
			
		||||
Inside that directory is a subdirectory for each draft or version of the
 | 
			
		||||
schema. We'll use `draft3` as an example.
 | 
			
		||||
 | 
			
		||||
If you look inside the draft directory, there are a number of `.json` files,
 | 
			
		||||
which logically group a set of test cases together. Often the grouping is by
 | 
			
		||||
property under test, but not always, especially within optional test files
 | 
			
		||||
(discussed below).
 | 
			
		||||
 | 
			
		||||
Inside each `.json` file is a single array containing objects. It's easiest to
 | 
			
		||||
illustrate the structure of these with an example:
 | 
			
		||||
 | 
			
		||||
```json
 | 
			
		||||
    {
 | 
			
		||||
        "description": "the description of the test case",
 | 
			
		||||
        "schema": {"the schema that should" : "be validated against"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a specific test of a valid instance",
 | 
			
		||||
                "data": "the instance",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "another specific test this time, invalid",
 | 
			
		||||
                "data": 15,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
So a description, a schema, and some tests, where tests is an array containing
 | 
			
		||||
one or more objects with descriptions, data, and a boolean indicating whether
 | 
			
		||||
they should be valid or invalid.
 | 
			
		||||
 | 
			
		||||
Coverage
 | 
			
		||||
--------
 | 
			
		||||
 | 
			
		||||
Currently, draft 3 should have essentially full coverage for the core schema.
 | 
			
		||||
 | 
			
		||||
The beginnings of draft 4 are underway.
 | 
			
		||||
 | 
			
		||||
Who Uses the Test Suite
 | 
			
		||||
-----------------------
 | 
			
		||||
 | 
			
		||||
This suite is being used by:
 | 
			
		||||
 | 
			
		||||
  * [json-schema-validator (Java)](https://github.com/fge/json-schema-validator)
 | 
			
		||||
  * [jsonschema (python)](https://github.com/Julian/jsonschema)
 | 
			
		||||
  * [aeson-schema (haskell)](https://github.com/timjb/aeson-schema)
 | 
			
		||||
  * [direct-schema (javascript)](https://github.com/IreneKnapp/direct-schema)
 | 
			
		||||
  * [jsonschema (javascript)](https://github.com/tdegrunt/jsonschema)
 | 
			
		||||
  * [JaySchema (javascript)](https://github.com/natesilva/jayschema)
 | 
			
		||||
  * [jesse (Erlang)](https://github.com/klarna/jesse)
 | 
			
		||||
 | 
			
		||||
If you use it as well, please fork and send a pull request adding yourself to
 | 
			
		||||
the list :).
 | 
			
		||||
 | 
			
		||||
Contributing
 | 
			
		||||
------------
 | 
			
		||||
 | 
			
		||||
If you see something missing or incorrect, a pull request is most welcome!
 | 
			
		||||
							
								
								
									
										277
									
								
								bin/jsonschema_suite
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										277
									
								
								bin/jsonschema_suite
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,277 @@
 | 
			
		||||
#! /usr/bin/env python
 | 
			
		||||
import sys
 | 
			
		||||
import textwrap
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    import argparse
 | 
			
		||||
except ImportError:
 | 
			
		||||
    print textwrap.dedent("""
 | 
			
		||||
        The argparse library could not be imported. jsonschema_suite requires
 | 
			
		||||
        either Python 2.7 or for you to install argparse. You can do so by
 | 
			
		||||
        running `pip install argparse`, `easy_install argparse` or by
 | 
			
		||||
        downloading argparse and running `python2.6 setup.py install`.
 | 
			
		||||
 | 
			
		||||
        See https://pypi.python.org/pypi/argparse for details.
 | 
			
		||||
    """.strip("\n"))
 | 
			
		||||
    sys.exit(1)
 | 
			
		||||
 | 
			
		||||
import errno
 | 
			
		||||
import fnmatch
 | 
			
		||||
import json
 | 
			
		||||
import os
 | 
			
		||||
import random
 | 
			
		||||
import shutil
 | 
			
		||||
import unittest
 | 
			
		||||
import warnings
 | 
			
		||||
 | 
			
		||||
if getattr(unittest, "skipIf", None) is None:
 | 
			
		||||
    unittest.skipIf = lambda cond, msg : lambda fn : fn
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    import jsonschema
 | 
			
		||||
except ImportError:
 | 
			
		||||
    jsonschema = None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
ROOT_DIR = os.path.join(os.path.dirname(__file__), os.pardir)
 | 
			
		||||
SUITE_ROOT_DIR = os.path.join(ROOT_DIR, "tests")
 | 
			
		||||
 | 
			
		||||
REMOTES = {
 | 
			
		||||
    "integer.json": {"type": "integer"},
 | 
			
		||||
    "subSchemas.json": {
 | 
			
		||||
        "integer": {"type": "integer"},
 | 
			
		||||
        "refToInteger": {"$ref": "#/integer"},
 | 
			
		||||
    },
 | 
			
		||||
    "folder/folderInteger.json": {"type": "integer"}
 | 
			
		||||
}
 | 
			
		||||
REMOTES_DIR = os.path.join(ROOT_DIR, "remotes")
 | 
			
		||||
 | 
			
		||||
TESTSUITE_SCHEMA = {
 | 
			
		||||
    "$schema": "http://json-schema.org/draft-03/schema#",
 | 
			
		||||
    "type": "array",
 | 
			
		||||
    "items": {
 | 
			
		||||
        "type": "object",
 | 
			
		||||
        "properties": {
 | 
			
		||||
            "description": {"type": "string", "required": True},
 | 
			
		||||
            "schema": {"required": True},
 | 
			
		||||
            "tests": {
 | 
			
		||||
                "type": "array",
 | 
			
		||||
                "items": {
 | 
			
		||||
                    "type": "object",
 | 
			
		||||
                    "properties": {
 | 
			
		||||
                        "description": {"type": "string", "required": True},
 | 
			
		||||
                        "data": {"required": True},
 | 
			
		||||
                        "valid": {"type": "boolean", "required": True}
 | 
			
		||||
                    },
 | 
			
		||||
                    "additionalProperties": False
 | 
			
		||||
                },
 | 
			
		||||
                "minItems": 1
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "additionalProperties": False,
 | 
			
		||||
        "minItems": 1
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def files(paths):
 | 
			
		||||
    for path in paths:
 | 
			
		||||
        with open(path) as test_file:
 | 
			
		||||
            yield json.load(test_file)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def groups(paths):
 | 
			
		||||
    for test_file in files(paths):
 | 
			
		||||
        for group in test_file:
 | 
			
		||||
            yield group
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def cases(paths):
 | 
			
		||||
    for test_group in groups(paths):
 | 
			
		||||
        for test in test_group["tests"]:
 | 
			
		||||
            test["schema"] = test_group["schema"]
 | 
			
		||||
            yield test
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def collect(root_dir):
 | 
			
		||||
    for root, dirs, files in os.walk(root_dir):
 | 
			
		||||
        for filename in fnmatch.filter(files, "*.json"):
 | 
			
		||||
            yield os.path.join(root, filename)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class SanityTests(unittest.TestCase):
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def setUpClass(cls):
 | 
			
		||||
        print "Looking for tests in %s" % SUITE_ROOT_DIR
 | 
			
		||||
        cls.test_files = list(collect(SUITE_ROOT_DIR))
 | 
			
		||||
        print "Found %s test files" % len(cls.test_files)
 | 
			
		||||
        assert cls.test_files, "Didn't find the test files!"
 | 
			
		||||
 | 
			
		||||
    def test_all_files_are_valid_json(self):
 | 
			
		||||
        for path in self.test_files:
 | 
			
		||||
            with open(path) as test_file:
 | 
			
		||||
                try:
 | 
			
		||||
                    json.load(test_file)
 | 
			
		||||
                except ValueError as error:
 | 
			
		||||
                    self.fail("%s contains invalid JSON (%s)" % (path, error))
 | 
			
		||||
 | 
			
		||||
    def test_all_descriptions_have_reasonable_length(self):
 | 
			
		||||
        for case in cases(self.test_files):
 | 
			
		||||
            descript = case["description"]
 | 
			
		||||
            self.assertLess(
 | 
			
		||||
                len(descript),
 | 
			
		||||
                60,
 | 
			
		||||
                "%r is too long! (keep it to less than 60 chars)" % (descript,)
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
    def test_all_descriptions_are_unique(self):
 | 
			
		||||
        for group in groups(self.test_files):
 | 
			
		||||
            descriptions = set(test["description"] for test in group["tests"])
 | 
			
		||||
            self.assertEqual(
 | 
			
		||||
                len(descriptions),
 | 
			
		||||
                len(group["tests"]),
 | 
			
		||||
                "%r contains a duplicate description" % (group,)
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
    @unittest.skipIf(jsonschema is None, "Validation library not present!")
 | 
			
		||||
    def test_all_schemas_are_valid(self):
 | 
			
		||||
        for schema in os.listdir(SUITE_ROOT_DIR):
 | 
			
		||||
            schema_validator = jsonschema.validators.get(schema)
 | 
			
		||||
            if schema_validator:
 | 
			
		||||
                test_files = collect(os.path.join(SUITE_ROOT_DIR, schema))
 | 
			
		||||
                for case in cases(test_files):
 | 
			
		||||
                    try:
 | 
			
		||||
                        schema_validator.check_schema(case["schema"])
 | 
			
		||||
                    except jsonschema.SchemaError as error:
 | 
			
		||||
                        self.fail("%s contains an invalid schema (%s)" %
 | 
			
		||||
                                  (case, error))
 | 
			
		||||
            else:
 | 
			
		||||
                warnings.warn("No schema validator for %s" % schema)
 | 
			
		||||
 | 
			
		||||
    @unittest.skipIf(jsonschema is None, "Validation library not present!")
 | 
			
		||||
    def test_suites_are_valid(self):
 | 
			
		||||
        validator = jsonschema.Draft3Validator(TESTSUITE_SCHEMA)
 | 
			
		||||
        for tests in files(self.test_files):
 | 
			
		||||
            try:
 | 
			
		||||
                validator.validate(tests)
 | 
			
		||||
            except jsonschema.ValidationError as error:
 | 
			
		||||
                self.fail(str(error))
 | 
			
		||||
 | 
			
		||||
    def test_remote_schemas_are_updated(self):
 | 
			
		||||
        for url, schema in REMOTES.iteritems():
 | 
			
		||||
            filepath = os.path.join(REMOTES_DIR, url)
 | 
			
		||||
            with open(filepath) as schema_file:
 | 
			
		||||
                self.assertEqual(json.load(schema_file), schema)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def main(arguments):
 | 
			
		||||
    if arguments.command == "check":
 | 
			
		||||
        suite = unittest.TestLoader().loadTestsFromTestCase(SanityTests)
 | 
			
		||||
        result = unittest.TextTestRunner(verbosity=2).run(suite)
 | 
			
		||||
        sys.exit(not result.wasSuccessful())
 | 
			
		||||
    elif arguments.command == "flatten":
 | 
			
		||||
        selected_cases = [case for case in cases(collect(arguments.version))]
 | 
			
		||||
 | 
			
		||||
        if arguments.randomize:
 | 
			
		||||
            random.shuffle(selected_cases)
 | 
			
		||||
 | 
			
		||||
        json.dump(selected_cases, sys.stdout, indent=4, sort_keys=True)
 | 
			
		||||
    elif arguments.command == "remotes":
 | 
			
		||||
        json.dump(REMOTES, sys.stdout, indent=4, sort_keys=True)
 | 
			
		||||
    elif arguments.command == "dump_remotes":
 | 
			
		||||
        if arguments.update:
 | 
			
		||||
            shutil.rmtree(arguments.out_dir, ignore_errors=True)
 | 
			
		||||
 | 
			
		||||
        try:
 | 
			
		||||
            os.makedirs(arguments.out_dir)
 | 
			
		||||
        except OSError as e:
 | 
			
		||||
            if e.errno == errno.EEXIST:
 | 
			
		||||
                print "%s already exists. Aborting." % arguments.out_dir
 | 
			
		||||
                sys.exit(1)
 | 
			
		||||
            raise
 | 
			
		||||
 | 
			
		||||
        for url, schema in REMOTES.iteritems():
 | 
			
		||||
            filepath = os.path.join(arguments.out_dir, url)
 | 
			
		||||
 | 
			
		||||
            try:
 | 
			
		||||
                os.makedirs(os.path.dirname(filepath))
 | 
			
		||||
            except OSError as e:
 | 
			
		||||
                if e.errno != errno.EEXIST:
 | 
			
		||||
                    raise
 | 
			
		||||
 | 
			
		||||
            with open(filepath, "wb") as out_file:
 | 
			
		||||
                json.dump(schema, out_file, indent=4, sort_keys=True)
 | 
			
		||||
    elif arguments.command == "serve":
 | 
			
		||||
        try:
 | 
			
		||||
            from flask import Flask, jsonify
 | 
			
		||||
        except ImportError:
 | 
			
		||||
            print textwrap.dedent("""
 | 
			
		||||
                The Flask library is required to serve the remote schemas.
 | 
			
		||||
 | 
			
		||||
                You can install it by running `pip install Flask`.
 | 
			
		||||
 | 
			
		||||
                Alternatively, see the `jsonschema_suite remotes` or
 | 
			
		||||
                `jsonschema_suite dump_remotes` commands to create static files
 | 
			
		||||
                that can be served with your own web server.
 | 
			
		||||
            """.strip("\n"))
 | 
			
		||||
            sys.exit(1)
 | 
			
		||||
 | 
			
		||||
        app = Flask(__name__)
 | 
			
		||||
 | 
			
		||||
        @app.route("/<path:path>")
 | 
			
		||||
        def serve_path(path):
 | 
			
		||||
            if path in REMOTES:
 | 
			
		||||
                return jsonify(REMOTES[path])
 | 
			
		||||
            return "Document does not exist.", 404
 | 
			
		||||
 | 
			
		||||
        app.run(port=1234)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
parser = argparse.ArgumentParser(
 | 
			
		||||
    description="JSON Schema Test Suite utilities",
 | 
			
		||||
)
 | 
			
		||||
subparsers = parser.add_subparsers(help="utility commands", dest="command")
 | 
			
		||||
 | 
			
		||||
check = subparsers.add_parser("check", help="Sanity check the test suite.")
 | 
			
		||||
 | 
			
		||||
flatten = subparsers.add_parser(
 | 
			
		||||
    "flatten",
 | 
			
		||||
    help="Output a flattened file containing a selected version's test cases."
 | 
			
		||||
)
 | 
			
		||||
flatten.add_argument(
 | 
			
		||||
    "--randomize",
 | 
			
		||||
    action="store_true",
 | 
			
		||||
    help="Randomize the order of the outputted cases.",
 | 
			
		||||
)
 | 
			
		||||
flatten.add_argument(
 | 
			
		||||
    "version", help="The directory containing the version to output",
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
remotes = subparsers.add_parser(
 | 
			
		||||
    "remotes",
 | 
			
		||||
    help="Output the expected URLs and their associated schemas for remote "
 | 
			
		||||
         "ref tests as a JSON object."
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
dump_remotes = subparsers.add_parser(
 | 
			
		||||
    "dump_remotes", help="Dump the remote ref schemas into a file tree",
 | 
			
		||||
)
 | 
			
		||||
dump_remotes.add_argument(
 | 
			
		||||
    "--update",
 | 
			
		||||
    action="store_true",
 | 
			
		||||
    help="Update the remotes in an existing directory.",
 | 
			
		||||
)
 | 
			
		||||
dump_remotes.add_argument(
 | 
			
		||||
    "--out-dir",
 | 
			
		||||
    default=REMOTES_DIR,
 | 
			
		||||
    type=os.path.abspath,
 | 
			
		||||
    help="The output directory to create as the root of the file tree",
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
serve = subparsers.add_parser(
 | 
			
		||||
    "serve",
 | 
			
		||||
    help="Start a webserver to serve schemas used by remote ref tests."
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    main(parser.parse_args())
 | 
			
		||||
							
								
								
									
										3
									
								
								remotes/folder/folderInteger.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								remotes/folder/folderInteger.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "integer"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										3
									
								
								remotes/integer.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								remotes/integer.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "integer"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										8
									
								
								remotes/subSchemas.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								remotes/subSchemas.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
{
 | 
			
		||||
    "integer": {
 | 
			
		||||
        "type": "integer"
 | 
			
		||||
    }, 
 | 
			
		||||
    "refToInteger": {
 | 
			
		||||
        "$ref": "#/integer"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										82
									
								
								tests/draft3/additionalItems.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								tests/draft3/additionalItems.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,82 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "additionalItems as schema",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "items": [],
 | 
			
		||||
            "additionalItems": {"type": "integer"}
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "additional items match schema",
 | 
			
		||||
                "data": [ 1, 2, 3, 4 ],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "additional items do not match schema",
 | 
			
		||||
                "data": [ 1, 2, 3, "foo" ],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "items is schema, no additionalItems",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "items": {},
 | 
			
		||||
            "additionalItems": false
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "all items match schema",
 | 
			
		||||
                "data": [ 1, 2, 3, 4, 5 ],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "array of items with no additionalItems",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "items": [{}, {}, {}],
 | 
			
		||||
            "additionalItems": false
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "no additional items present",
 | 
			
		||||
                "data": [ 1, 2, 3 ],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "additional items are not permitted",
 | 
			
		||||
                "data": [ 1, 2, 3, 4 ],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "additionalItems as false without items",
 | 
			
		||||
        "schema": {"additionalItems": false},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description":
 | 
			
		||||
                    "items defaults to empty schema so everything is valid",
 | 
			
		||||
                "data": [ 1, 2, 3, 4, 5 ],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-arrays",
 | 
			
		||||
                "data": {"foo" : "bar"},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "additionalItems are allowed by default",
 | 
			
		||||
        "schema": {"items": []},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "only the first items are validated",
 | 
			
		||||
                "data": [1, "foo", false],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										63
									
								
								tests/draft3/additionalProperties.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								tests/draft3/additionalProperties.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,63 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description":
 | 
			
		||||
            "additionalProperties being false does not allow other properties",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {"foo": {}, "bar": {}},
 | 
			
		||||
            "additionalProperties": false
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "no additional properties is valid",
 | 
			
		||||
                "data": {"foo": 1},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an additional property is invalid",
 | 
			
		||||
                "data": {"foo" : 1, "bar" : 2, "quux" : "boom"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-objects",
 | 
			
		||||
                "data": [1, 2, 3],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description":
 | 
			
		||||
            "additionalProperties allows a schema which should validate",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {"foo": {}, "bar": {}},
 | 
			
		||||
            "additionalProperties": {"type": "boolean"}
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "no additional properties is valid",
 | 
			
		||||
                "data": {"foo": 1},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an additional valid property is valid",
 | 
			
		||||
                "data": {"foo" : 1, "bar" : 2, "quux" : true},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an additional invalid property is invalid",
 | 
			
		||||
                "data": {"foo" : 1, "bar" : 2, "quux" : 12},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "additionalProperties are allowed by default",
 | 
			
		||||
        "schema": {"properties": {"foo": {}, "bar": {}}},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "additional properties are allowed",
 | 
			
		||||
                "data": {"foo": 1, "bar": 2, "quux": true},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										108
									
								
								tests/draft3/dependencies.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										108
									
								
								tests/draft3/dependencies.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,108 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "dependencies",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "dependencies": {"bar": "foo"}
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "neither",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "nondependant",
 | 
			
		||||
                "data": {"foo": 1},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "with dependency",
 | 
			
		||||
                "data": {"foo": 1, "bar": 2},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "missing dependency",
 | 
			
		||||
                "data": {"bar": 2},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-objects",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "multiple dependencies",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "dependencies": {"quux": ["foo", "bar"]}
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "neither",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "nondependants",
 | 
			
		||||
                "data": {"foo": 1, "bar": 2},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "with dependencies",
 | 
			
		||||
                "data": {"foo": 1, "bar": 2, "quux": 3},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "missing dependency",
 | 
			
		||||
                "data": {"foo": 1, "quux": 2},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "missing other dependency",
 | 
			
		||||
                "data": {"bar": 1, "quux": 2},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "missing both dependencies",
 | 
			
		||||
                "data": {"quux": 1},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "multiple dependencies subschema",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "dependencies": {
 | 
			
		||||
                "bar": {
 | 
			
		||||
                    "properties": {
 | 
			
		||||
                        "foo": {"type": "integer"},
 | 
			
		||||
                        "bar": {"type": "integer"}
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "valid",
 | 
			
		||||
                "data": {"foo": 1, "bar": 2},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "wrong type",
 | 
			
		||||
                "data": {"foo": "quux", "bar": 2},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "wrong type other",
 | 
			
		||||
                "data": {"foo": 2, "bar": "quux"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "wrong type both",
 | 
			
		||||
                "data": {"foo": "quux", "bar": "quux"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										80
									
								
								tests/draft3/disallow.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								tests/draft3/disallow.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,80 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "disallow",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "disallow": "integer"
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "allowed",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "disallowed",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "multiple disallow",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "disallow": ["integer", "boolean"]
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "valid",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "other mismatch",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "multiple disallow subschema",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "disallow":
 | 
			
		||||
                ["string",
 | 
			
		||||
                 {
 | 
			
		||||
                    "type": "object",
 | 
			
		||||
                    "properties": {
 | 
			
		||||
                        "foo": {
 | 
			
		||||
                            "type": "string"
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                 }]
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "match",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "other match",
 | 
			
		||||
                "data": {"foo": 1},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "other mismatch",
 | 
			
		||||
                "data": {"foo": "bar"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										60
									
								
								tests/draft3/divisibleBy.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								tests/draft3/divisibleBy.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,60 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "by int",
 | 
			
		||||
        "schema": {"divisibleBy": 2},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "int by int",
 | 
			
		||||
                "data": 10,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "int by int fail",
 | 
			
		||||
                "data": 7,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-numbers",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "by number",
 | 
			
		||||
        "schema": {"divisibleBy": 1.5},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "zero is divisible by anything (except 0)",
 | 
			
		||||
                "data": 0,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "4.5 is divisible by 1.5",
 | 
			
		||||
                "data": 4.5,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "35 is not divisible by 1.5",
 | 
			
		||||
                "data": 35,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "by small number",
 | 
			
		||||
        "schema": {"divisibleBy": 0.0001},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "0.0075 is divisible by 0.0001",
 | 
			
		||||
                "data": 0.0075,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "0.00751 is not divisible by 0.0001",
 | 
			
		||||
                "data": 0.00751,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										39
									
								
								tests/draft3/enum.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								tests/draft3/enum.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "simple enum validation",
 | 
			
		||||
        "schema": {"enum": [1, 2, 3]},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "one of the enum is valid",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "something else is invalid",
 | 
			
		||||
                "data": 4,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "heterogeneous enum validation",
 | 
			
		||||
        "schema": {"enum": [6, "foo", [], true, {"foo": 12}]},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "one of the enum is valid",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "something else is invalid",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "objects are deep compared",
 | 
			
		||||
                "data": {"foo": false},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										94
									
								
								tests/draft3/extends.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								tests/draft3/extends.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,94 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "extends",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {"bar": {"type": "integer", "required": true}},
 | 
			
		||||
            "extends": {
 | 
			
		||||
                "properties": {
 | 
			
		||||
                    "foo": {"type": "string", "required": true}
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "extends",
 | 
			
		||||
                "data": {"foo": "baz", "bar": 2},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch extends",
 | 
			
		||||
                "data": {"foo": "baz"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch extended",
 | 
			
		||||
                "data": {"bar": 2},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "wrong type",
 | 
			
		||||
                "data": {"foo": "baz", "bar": "quux"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "multiple extends",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {"bar": {"type": "integer", "required": true}},
 | 
			
		||||
            "extends" : [
 | 
			
		||||
                {
 | 
			
		||||
                    "properties": {
 | 
			
		||||
                        "foo": {"type": "string", "required": true}
 | 
			
		||||
                    }
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "properties": {
 | 
			
		||||
                        "baz": {"type": "null", "required": true}
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            ]
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "valid",
 | 
			
		||||
                "data": {"foo": "quux", "bar": 2, "baz": null},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch first extends",
 | 
			
		||||
                "data": {"bar": 2, "baz": null},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch second extends",
 | 
			
		||||
                "data": {"foo": "quux", "bar": 2},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch both",
 | 
			
		||||
                "data": {"bar": 2},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "extends simple types",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "minimum": 20,
 | 
			
		||||
            "extends": {"maximum": 30}
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "valid",
 | 
			
		||||
                "data": 25,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch extends",
 | 
			
		||||
                "data": 35,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										46
									
								
								tests/draft3/items.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								tests/draft3/items.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "a schema given for items",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "items": {"type": "integer"}
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "valid items",
 | 
			
		||||
                "data": [ 1, 2, 3 ],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "wrong type of items",
 | 
			
		||||
                "data": [1, "x"],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-arrays",
 | 
			
		||||
                "data": {"foo" : "bar"},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "an array of schemas for items",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "items": [
 | 
			
		||||
                {"type": "integer"},
 | 
			
		||||
                {"type": "string"}
 | 
			
		||||
            ]
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "correct types",
 | 
			
		||||
                "data": [ 1, "foo" ],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "wrong types",
 | 
			
		||||
                "data": [ "foo", 1 ],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										28
									
								
								tests/draft3/maxItems.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								tests/draft3/maxItems.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "maxItems validation",
 | 
			
		||||
        "schema": {"maxItems": 2},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "shorter is valid",
 | 
			
		||||
                "data": [1],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "exact length is valid",
 | 
			
		||||
                "data": [1, 2],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "too long is invalid",
 | 
			
		||||
                "data": [1, 2, 3],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-arrays",
 | 
			
		||||
                "data": "foobar",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										28
									
								
								tests/draft3/maxLength.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								tests/draft3/maxLength.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "maxLength validation",
 | 
			
		||||
        "schema": {"maxLength": 2},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "shorter is valid",
 | 
			
		||||
                "data": "f",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "exact length is valid",
 | 
			
		||||
                "data": "fo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "too long is invalid",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-strings",
 | 
			
		||||
                "data": 10,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										42
									
								
								tests/draft3/maximum.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								tests/draft3/maximum.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "maximum validation",
 | 
			
		||||
        "schema": {"maximum": 3.0},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "below the maximum is valid",
 | 
			
		||||
                "data": 2.6,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "above the maximum is invalid",
 | 
			
		||||
                "data": 3.5,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-numbers",
 | 
			
		||||
                "data": "x",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "exclusiveMaximum validation",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "maximum": 3.0,
 | 
			
		||||
            "exclusiveMaximum": true
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "below the maximum is still valid",
 | 
			
		||||
                "data": 2.2,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "boundary point is invalid",
 | 
			
		||||
                "data": 3.0,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										28
									
								
								tests/draft3/minItems.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								tests/draft3/minItems.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "minItems validation",
 | 
			
		||||
        "schema": {"minItems": 1},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "longer is valid",
 | 
			
		||||
                "data": [1, 2],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "exact length is valid",
 | 
			
		||||
                "data": [1],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "too short is invalid",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-arrays",
 | 
			
		||||
                "data": "",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										28
									
								
								tests/draft3/minLength.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								tests/draft3/minLength.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "minLength validation",
 | 
			
		||||
        "schema": {"minLength": 2},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "longer is valid",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "exact length is valid",
 | 
			
		||||
                "data": "fo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "too short is invalid",
 | 
			
		||||
                "data": "f",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-strings",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										42
									
								
								tests/draft3/minimum.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								tests/draft3/minimum.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "minimum validation",
 | 
			
		||||
        "schema": {"minimum": 1.1},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "above the minimum is valid",
 | 
			
		||||
                "data": 2.6,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "below the minimum is invalid",
 | 
			
		||||
                "data": 0.6,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-numbers",
 | 
			
		||||
                "data": "x",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "exclusiveMinimum validation",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "minimum": 1.1,
 | 
			
		||||
            "exclusiveMinimum": true
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "above the minimum is still valid",
 | 
			
		||||
                "data": 1.2,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "boundary point is invalid",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										49
									
								
								tests/draft3/optional/bignum.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								tests/draft3/optional/bignum.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "integer",
 | 
			
		||||
        "schema": {"type": "integer"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a bignum is an integer",
 | 
			
		||||
                "data": 12345678910111213141516171819202122232425262728293031,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "number",
 | 
			
		||||
        "schema": {"type": "number"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a bignum is a number",
 | 
			
		||||
                "data": 98249283749234923498293171823948729348710298301928331,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "string",
 | 
			
		||||
        "schema": {"type": "string"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a bignum is not a string",
 | 
			
		||||
                "data": 98249283749234923498293171823948729348710298301928331,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "float comparison with high precision",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "maximum": 972783798187987123879878123.18878137,
 | 
			
		||||
            "exclusiveMaximum": true
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "comparison works for high numbers",
 | 
			
		||||
                "data": 972783798187987123879878123.188781371,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										207
									
								
								tests/draft3/optional/format.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										207
									
								
								tests/draft3/optional/format.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,207 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "validation of regular expressions",
 | 
			
		||||
        "schema": {"format": "regex"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid regular expression",
 | 
			
		||||
                "data": "([abc])+\\s+$",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a regular expression with unclosed parens is invalid",
 | 
			
		||||
                "data": "^(abc]",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "validation of date-time strings",
 | 
			
		||||
        "schema": {"format": "date-time"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid date-time string",
 | 
			
		||||
                "data": "1963-06-19T08:30:06.283185Z",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an invalid date-time string",
 | 
			
		||||
                "data": "06/19/1963 08:30:06 PST",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "validation of date strings",
 | 
			
		||||
        "schema": {"format": "date"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid date string",
 | 
			
		||||
                "data": "1963-06-19",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an invalid date string",
 | 
			
		||||
                "data": "06/19/1963",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "validation of time strings",
 | 
			
		||||
        "schema": {"format": "time"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid time string",
 | 
			
		||||
                "data": "08:30:06",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an invalid time string",
 | 
			
		||||
                "data": "8:30 AM",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "validation of URIs",
 | 
			
		||||
        "schema": {"format": "uri"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid URI",
 | 
			
		||||
                "data": "http://foo.bar/?baz=qux#quux",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an invalid URI",
 | 
			
		||||
                "data": "\\\\WINDOWS\\fileshare",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "validation of e-mail addresses",
 | 
			
		||||
        "schema": {"format": "email"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid e-mail address",
 | 
			
		||||
                "data": "joe.bloggs@example.com",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an invalid e-mail address",
 | 
			
		||||
                "data": "2962",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "validation of IP addresses",
 | 
			
		||||
        "schema": {"format": "ip-address"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid IP address",
 | 
			
		||||
                "data": "192.168.0.1",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an IP address with too many components",
 | 
			
		||||
                "data": "127.0.0.0.1",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an IP address with out-of-range values",
 | 
			
		||||
                "data": "256.256.256.256",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "validation of IPv6 addresses",
 | 
			
		||||
        "schema": {"format": "ipv6"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid IPv6 address",
 | 
			
		||||
                "data": "::1",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an IPv6 address with out-of-range values",
 | 
			
		||||
                "data": "12345::",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an IPv6 address with too many components",
 | 
			
		||||
                "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an IPv6 address containing illegal characters",
 | 
			
		||||
                "data": "::laptop",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "validation of host names",
 | 
			
		||||
        "schema": {"format": "host-name"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid host name",
 | 
			
		||||
                "data": "www.example.com",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a host name starting with an illegal character",
 | 
			
		||||
                "data": "-a-host-name-that-starts-with--",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a host name containing illegal characters",
 | 
			
		||||
                "data": "not_a_valid_host_name",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a host name with a component too long",
 | 
			
		||||
                "data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "validation of CSS colors",
 | 
			
		||||
        "schema": {"format": "color"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid CSS color name",
 | 
			
		||||
                "data": "fuchsia",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid six-digit CSS color code",
 | 
			
		||||
                "data": "#CC8899",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid three-digit CSS color code",
 | 
			
		||||
                "data": "#C89",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an invalid CSS color code",
 | 
			
		||||
                "data": "#00332520",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an invalid CSS color name",
 | 
			
		||||
                "data": "puce",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a CSS color name containing invalid characters",
 | 
			
		||||
                "data": "light_grayish_red-violet",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										18
									
								
								tests/draft3/optional/jsregex.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								tests/draft3/optional/jsregex.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "ECMA 262 regex dialect recognition",
 | 
			
		||||
        "schema": { "format": "pattern" },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "[^] is a valid regex",
 | 
			
		||||
                "data": "[^]",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ECMA 262 has no support for lookbehind",
 | 
			
		||||
                "data": "(?<=foo)bar",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										15
									
								
								tests/draft3/optional/zeroTerminatedFloats.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								tests/draft3/optional/zeroTerminatedFloats.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "some languages do not distinguish between different types of numeric value",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "type": "integer"
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is not an integer even without fractional part",
 | 
			
		||||
                "data": 1.0,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										23
									
								
								tests/draft3/pattern.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								tests/draft3/pattern.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "pattern validation",
 | 
			
		||||
        "schema": {"pattern": "^a*$"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a matching pattern is valid",
 | 
			
		||||
                "data": "aaa",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a non-matching pattern is invalid",
 | 
			
		||||
                "data": "abc",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-strings",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										110
									
								
								tests/draft3/patternProperties.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								tests/draft3/patternProperties.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,110 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description":
 | 
			
		||||
            "patternProperties validates properties matching a regex",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "patternProperties": {
 | 
			
		||||
                "f.*o": {"type": "integer"}
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a single valid match is valid",
 | 
			
		||||
                "data": {"foo": 1},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "multiple valid matches is valid",
 | 
			
		||||
                "data": {"foo": 1, "foooooo" : 2},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a single invalid match is invalid",
 | 
			
		||||
                "data": {"foo": "bar", "fooooo": 2},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "multiple invalid matches is invalid",
 | 
			
		||||
                "data": {"foo": "bar", "foooooo" : "baz"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-objects",
 | 
			
		||||
                "data": 12,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "multiple simultaneous patternProperties are validated",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "patternProperties": {
 | 
			
		||||
                "a*": {"type": "integer"},
 | 
			
		||||
                "aaa*": {"maximum": 20}
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a single valid match is valid",
 | 
			
		||||
                "data": {"a": 21},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a simultaneous match is valid",
 | 
			
		||||
                "data": {"aaaa": 18},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "multiple matches is valid",
 | 
			
		||||
                "data": {"a": 21, "aaaa": 18},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an invalid due to one is invalid",
 | 
			
		||||
                "data": {"a": "bar"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an invalid due to the other is invalid",
 | 
			
		||||
                "data": {"aaaa": 31},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an invalid due to both is invalid",
 | 
			
		||||
                "data": {"aaa": "foo", "aaaa": 31},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "regexes are not anchored by default and are case sensitive",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "patternProperties": {
 | 
			
		||||
                "[0-9]{2,}": { "type": "boolean" },
 | 
			
		||||
                "X_": { "type": "string" }
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "non recognized members are ignored",
 | 
			
		||||
                "data": { "answer 1": "42" },
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "recognized members are accounted for",
 | 
			
		||||
                "data": { "a31b": null },
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "regexes are case sensitive",
 | 
			
		||||
                "data": { "a_x_3": 3 },
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "regexes are case sensitive, 2",
 | 
			
		||||
                "data": { "a_X_3": 3 },
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										92
									
								
								tests/draft3/properties.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								tests/draft3/properties.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,92 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "object properties validation",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {
 | 
			
		||||
                "foo": {"type": "integer"},
 | 
			
		||||
                "bar": {"type": "string"}
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "both properties present and valid is valid",
 | 
			
		||||
                "data": {"foo": 1, "bar": "baz"},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "one property invalid is invalid",
 | 
			
		||||
                "data": {"foo": 1, "bar": {}},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "both properties invalid is invalid",
 | 
			
		||||
                "data": {"foo": [], "bar": {}},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "doesn't invalidate other properties",
 | 
			
		||||
                "data": {"quux": []},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-objects",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description":
 | 
			
		||||
            "properties, patternProperties, additionalProperties interaction",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {
 | 
			
		||||
                "foo": {"type": "array", "maxItems": 3},
 | 
			
		||||
                "bar": {"type": "array"}
 | 
			
		||||
            },
 | 
			
		||||
            "patternProperties": {"f.o": {"minItems": 2}},
 | 
			
		||||
            "additionalProperties": {"type": "integer"}
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "property validates property",
 | 
			
		||||
                "data": {"foo": [1, 2]},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "property invalidates property",
 | 
			
		||||
                "data": {"foo": [1, 2, 3, 4]},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "patternProperty invalidates property",
 | 
			
		||||
                "data": {"foo": []},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "patternProperty validates nonproperty",
 | 
			
		||||
                "data": {"fxo": [1, 2]},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "patternProperty invalidates nonproperty",
 | 
			
		||||
                "data": {"fxo": []},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "additionalProperty ignores property",
 | 
			
		||||
                "data": {"bar": []},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "additionalProperty validates others",
 | 
			
		||||
                "data": {"quux": 3},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "additionalProperty invalidates others",
 | 
			
		||||
                "data": {"quux": "foo"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										123
									
								
								tests/draft3/ref.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										123
									
								
								tests/draft3/ref.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,123 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "root pointer ref",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {
 | 
			
		||||
                "foo": {"$ref": "#"}
 | 
			
		||||
            },
 | 
			
		||||
            "additionalProperties": false
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "match",
 | 
			
		||||
                "data": {"foo": false},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "recursive match",
 | 
			
		||||
                "data": {"foo": {"foo": false}},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch",
 | 
			
		||||
                "data": {"bar": false},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "recursive mismatch",
 | 
			
		||||
                "data": {"foo": {"bar": false}},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "relative pointer ref",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {
 | 
			
		||||
                "foo": {"type": "integer"},
 | 
			
		||||
                "bar": {"$ref": "#/properties/foo"}
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "match",
 | 
			
		||||
                "data": {"bar": 3},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch",
 | 
			
		||||
                "data": {"bar": true},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "escaped pointer ref",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "tilda~field": {"type": "integer"},
 | 
			
		||||
            "slash/field": {"type": "integer"},
 | 
			
		||||
            "percent%field": {"type": "integer"},
 | 
			
		||||
            "properties": {
 | 
			
		||||
                "tilda": {"$ref": "#/tilda~0field"},
 | 
			
		||||
                "slash": {"$ref": "#/slash~1field"},
 | 
			
		||||
                "percent": {"$ref": "#/percent%25field"}
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "slash",
 | 
			
		||||
                "data": {"slash": "aoeu"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "tilda",
 | 
			
		||||
                "data": {"tilda": "aoeu"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "percent",
 | 
			
		||||
                "data": {"percent": "aoeu"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "nested refs",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "definitions": {
 | 
			
		||||
                "a": {"type": "integer"},
 | 
			
		||||
                "b": {"$ref": "#/definitions/a"},
 | 
			
		||||
                "c": {"$ref": "#/definitions/b"}
 | 
			
		||||
            },
 | 
			
		||||
            "$ref": "#/definitions/c"
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "nested ref valid",
 | 
			
		||||
                "data": 5,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "nested ref invalid",
 | 
			
		||||
                "data": "a",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "remote ref, containing refs itself",
 | 
			
		||||
        "schema": {"$ref": "http://json-schema.org/draft-03/schema#"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "remote ref valid",
 | 
			
		||||
                "data": {"items": {"type": "integer"}},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "remote ref invalid",
 | 
			
		||||
                "data": {"items": {"type": 1}},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										74
									
								
								tests/draft3/refRemote.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								tests/draft3/refRemote.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,74 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "remote ref",
 | 
			
		||||
        "schema": {"$ref": "http://localhost:1234/integer.json"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "remote ref valid",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "remote ref invalid",
 | 
			
		||||
                "data": "a",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "fragment within remote ref",
 | 
			
		||||
        "schema": {"$ref": "http://localhost:1234/subSchemas.json#/integer"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "remote fragment valid",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "remote fragment invalid",
 | 
			
		||||
                "data": "a",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "ref within remote ref",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "$ref": "http://localhost:1234/subSchemas.json#/refToInteger"
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ref within ref valid",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ref within ref invalid",
 | 
			
		||||
                "data": "a",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "change resolution scope",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "id": "http://localhost:1234/",
 | 
			
		||||
            "items": {
 | 
			
		||||
                "id": "folder/",
 | 
			
		||||
                "items": {"$ref": "folderInteger.json"}
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "changed scope ref valid",
 | 
			
		||||
                "data": [[1]],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "changed scope ref invalid",
 | 
			
		||||
                "data": [["a"]],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										53
									
								
								tests/draft3/required.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								tests/draft3/required.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "required validation",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {
 | 
			
		||||
                "foo": {"required" : true},
 | 
			
		||||
                "bar": {}
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "present required property is valid",
 | 
			
		||||
                "data": {"foo": 1},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "non-present required property is invalid",
 | 
			
		||||
                "data": {"bar": 1},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "required default validation",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {
 | 
			
		||||
                "foo": {}
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "not required by default",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "required explicitly false validation",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {
 | 
			
		||||
                "foo": {"required": false}
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "not required if required is false",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										474
									
								
								tests/draft3/type.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										474
									
								
								tests/draft3/type.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,474 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "integer type matches integers",
 | 
			
		||||
        "schema": {"type": "integer"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an integer is an integer",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is not an integer",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is not an integer",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is not an integer",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is not an integer",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a boolean is not an integer",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "null is not an integer",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "number type matches numbers",
 | 
			
		||||
        "schema": {"type": "number"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an integer is a number",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is a number",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is not a number",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is not a number",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is not a number",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a boolean is not a number",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "null is not a number",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "string type matches strings",
 | 
			
		||||
        "schema": {"type": "string"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "1 is not a string",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is not a string",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is a string",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is not a string",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is not a string",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a boolean is not a string",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "null is not a string",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "object type matches objects",
 | 
			
		||||
        "schema": {"type": "object"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an integer is not an object",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is not an object",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is not an object",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is an object",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is not an object",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a boolean is not an object",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "null is not an object",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "array type matches arrays",
 | 
			
		||||
        "schema": {"type": "array"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an integer is not an array",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is not an array",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is not an array",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is not an array",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is not an array",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a boolean is not an array",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "null is not an array",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "boolean type matches booleans",
 | 
			
		||||
        "schema": {"type": "boolean"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an integer is not a boolean",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is not a boolean",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is not a boolean",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is not a boolean",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is not a boolean",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a boolean is not a boolean",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "null is not a boolean",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "null type matches only the null object",
 | 
			
		||||
        "schema": {"type": "null"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an integer is not null",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is not null",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is not null",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is not null",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is not null",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a boolean is not null",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "null is null",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "any type matches any type",
 | 
			
		||||
        "schema": {"type": "any"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "any type includes integers",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "any type includes float",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "any type includes string",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "any type includes object",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "any type includes array",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "any type includes boolean",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "any type includes null",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "multiple types can be specified in an array",
 | 
			
		||||
        "schema": {"type": ["integer", "string"]},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an integer is valid",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is valid",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is invalid",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is invalid",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is invalid",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a boolean is invalid",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "null is invalid",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "types can include schemas",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "type": [
 | 
			
		||||
                "array",
 | 
			
		||||
                {"type": "object"}
 | 
			
		||||
            ]
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an integer is invalid",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is invalid",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is invalid",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is valid",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is valid",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a boolean is invalid",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "null is invalid",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": 
 | 
			
		||||
            "when types includes a schema it should fully validate the schema",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "type": [
 | 
			
		||||
                "integer",
 | 
			
		||||
                {
 | 
			
		||||
                    "properties": {
 | 
			
		||||
                        "foo": {"type": "null"}
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            ]
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an integer is valid",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is valid only if it is fully valid",
 | 
			
		||||
                "data": {"foo": null},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is invalid otherwise",
 | 
			
		||||
                "data": {"foo": "bar"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "types from separate schemas are merged",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "type": [
 | 
			
		||||
                {"type": ["string"]},
 | 
			
		||||
                {"type": ["array", "null"]}
 | 
			
		||||
            ]
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an integer is invalid",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is valid",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is valid",
 | 
			
		||||
                "data": [1, 2, 3],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										79
									
								
								tests/draft3/uniqueItems.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								tests/draft3/uniqueItems.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,79 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "uniqueItems validation",
 | 
			
		||||
        "schema": {"uniqueItems": true},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "unique array of integers is valid",
 | 
			
		||||
                "data": [1, 2],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "non-unique array of integers is invalid",
 | 
			
		||||
                "data": [1, 1],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "numbers are unique if mathematically unequal",
 | 
			
		||||
                "data": [1.0, 1.00, 1],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "unique array of objects is valid",
 | 
			
		||||
                "data": [{"foo": "bar"}, {"foo": "baz"}],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "non-unique array of objects is invalid",
 | 
			
		||||
                "data": [{"foo": "bar"}, {"foo": "bar"}],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "unique array of nested objects is valid",
 | 
			
		||||
                "data": [
 | 
			
		||||
                    {"foo": {"bar" : {"baz" : true}}},
 | 
			
		||||
                    {"foo": {"bar" : {"baz" : false}}}
 | 
			
		||||
                ],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "non-unique array of nested objects is invalid",
 | 
			
		||||
                "data": [
 | 
			
		||||
                    {"foo": {"bar" : {"baz" : true}}},
 | 
			
		||||
                    {"foo": {"bar" : {"baz" : true}}}
 | 
			
		||||
                ],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "unique array of arrays is valid",
 | 
			
		||||
                "data": [["foo"], ["bar"]],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "non-unique array of arrays is invalid",
 | 
			
		||||
                "data": [["foo"], ["foo"]],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "1 and true are unique",
 | 
			
		||||
                "data": [1, true],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "0 and false are unique",
 | 
			
		||||
                "data": [0, false],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "unique heterogeneous types are valid",
 | 
			
		||||
                "data": [{}, [1], true, null, 1],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "non-unique heterogeneous types are invalid",
 | 
			
		||||
                "data": [{}, [1], true, null, {}, 1],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										82
									
								
								tests/draft4/additionalItems.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								tests/draft4/additionalItems.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,82 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "additionalItems as schema",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "items": [{}],
 | 
			
		||||
            "additionalItems": {"type": "integer"}
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "additional items match schema",
 | 
			
		||||
                "data": [ null, 2, 3, 4 ],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "additional items do not match schema",
 | 
			
		||||
                "data": [ null, 2, 3, "foo" ],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "items is schema, no additionalItems",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "items": {},
 | 
			
		||||
            "additionalItems": false
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "all items match schema",
 | 
			
		||||
                "data": [ 1, 2, 3, 4, 5 ],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "array of items with no additionalItems",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "items": [{}, {}, {}],
 | 
			
		||||
            "additionalItems": false
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "no additional items present",
 | 
			
		||||
                "data": [ 1, 2, 3 ],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "additional items are not permitted",
 | 
			
		||||
                "data": [ 1, 2, 3, 4 ],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "additionalItems as false without items",
 | 
			
		||||
        "schema": {"additionalItems": false},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description":
 | 
			
		||||
                    "items defaults to empty schema so everything is valid",
 | 
			
		||||
                "data": [ 1, 2, 3, 4, 5 ],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-arrays",
 | 
			
		||||
                "data": {"foo" : "bar"},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "additionalItems are allowed by default",
 | 
			
		||||
        "schema": {"items": [{"type": "integer"}]},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "only the first item is validated",
 | 
			
		||||
                "data": [1, "foo", false],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										63
									
								
								tests/draft4/additionalProperties.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								tests/draft4/additionalProperties.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,63 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description":
 | 
			
		||||
            "additionalProperties being false does not allow other properties",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {"foo": {}, "bar": {}},
 | 
			
		||||
            "additionalProperties": false
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "no additional properties is valid",
 | 
			
		||||
                "data": {"foo": 1},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an additional property is invalid",
 | 
			
		||||
                "data": {"foo" : 1, "bar" : 2, "quux" : "boom"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-objects",
 | 
			
		||||
                "data": [1, 2, 3],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description":
 | 
			
		||||
            "additionalProperties allows a schema which should validate",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {"foo": {}, "bar": {}},
 | 
			
		||||
            "additionalProperties": {"type": "boolean"}
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "no additional properties is valid",
 | 
			
		||||
                "data": {"foo": 1},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an additional valid property is valid",
 | 
			
		||||
                "data": {"foo" : 1, "bar" : 2, "quux" : true},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an additional invalid property is invalid",
 | 
			
		||||
                "data": {"foo" : 1, "bar" : 2, "quux" : 12},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "additionalProperties are allowed by default",
 | 
			
		||||
        "schema": {"properties": {"foo": {}, "bar": {}}},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "additional properties are allowed",
 | 
			
		||||
                "data": {"foo": 1, "bar": 2, "quux": true},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										112
									
								
								tests/draft4/allOf.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										112
									
								
								tests/draft4/allOf.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,112 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "allOf",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "allOf": [
 | 
			
		||||
                {
 | 
			
		||||
                    "properties": {
 | 
			
		||||
                        "bar": {"type": "integer"}
 | 
			
		||||
                    },
 | 
			
		||||
                    "required": ["bar"]
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "properties": {
 | 
			
		||||
                        "foo": {"type": "string"}
 | 
			
		||||
                    },
 | 
			
		||||
                    "required": ["foo"]
 | 
			
		||||
                }
 | 
			
		||||
            ]
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "allOf",
 | 
			
		||||
                "data": {"foo": "baz", "bar": 2},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch second",
 | 
			
		||||
                "data": {"foo": "baz"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch first",
 | 
			
		||||
                "data": {"bar": 2},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "wrong type",
 | 
			
		||||
                "data": {"foo": "baz", "bar": "quux"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "allOf with base schema",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {"bar": {"type": "integer"}},
 | 
			
		||||
            "required": ["bar"],
 | 
			
		||||
            "allOf" : [
 | 
			
		||||
                {
 | 
			
		||||
                    "properties": {
 | 
			
		||||
                        "foo": {"type": "string"}
 | 
			
		||||
                    },
 | 
			
		||||
                    "required": ["foo"]
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "properties": {
 | 
			
		||||
                        "baz": {"type": "null"}
 | 
			
		||||
                    },
 | 
			
		||||
                    "required": ["baz"]
 | 
			
		||||
                }
 | 
			
		||||
            ]
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "valid",
 | 
			
		||||
                "data": {"foo": "quux", "bar": 2, "baz": null},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch base schema",
 | 
			
		||||
                "data": {"foo": "quux", "baz": null},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch first allOf",
 | 
			
		||||
                "data": {"bar": 2, "baz": null},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch second allOf",
 | 
			
		||||
                "data": {"foo": "quux", "bar": 2},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch both",
 | 
			
		||||
                "data": {"bar": 2},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "allOf simple types",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "allOf": [
 | 
			
		||||
                {"maximum": 30},
 | 
			
		||||
                {"minimum": 20}
 | 
			
		||||
            ]
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "valid",
 | 
			
		||||
                "data": 25,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch one",
 | 
			
		||||
                "data": 35,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										68
									
								
								tests/draft4/anyOf.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								tests/draft4/anyOf.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,68 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "anyOf",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "anyOf": [
 | 
			
		||||
                {
 | 
			
		||||
                    "type": "integer"
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "minimum": 2
 | 
			
		||||
                }
 | 
			
		||||
            ]
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "first anyOf valid",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "second anyOf valid",
 | 
			
		||||
                "data": 2.5,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "both anyOf valid",
 | 
			
		||||
                "data": 3,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "neither anyOf valid",
 | 
			
		||||
                "data": 1.5,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "anyOf with base schema",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "type": "string",
 | 
			
		||||
            "anyOf" : [
 | 
			
		||||
                {
 | 
			
		||||
                    "maxLength": 2
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "minLength": 4
 | 
			
		||||
                }
 | 
			
		||||
            ]
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch base schema",
 | 
			
		||||
                "data": 3,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "one anyOf valid",
 | 
			
		||||
                "data": "foobar",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "both anyOf invalid",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										32
									
								
								tests/draft4/definitions.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								tests/draft4/definitions.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "valid definition",
 | 
			
		||||
        "schema": {"$ref": "http://json-schema.org/draft-04/schema#"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "valid definition schema",
 | 
			
		||||
                "data": {
 | 
			
		||||
                    "definitions": {
 | 
			
		||||
                        "foo": {"type": "integer"}
 | 
			
		||||
                    }
 | 
			
		||||
                },
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "invalid definition",
 | 
			
		||||
        "schema": {"$ref": "http://json-schema.org/draft-04/schema#"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "invalid definition schema",
 | 
			
		||||
                "data": {
 | 
			
		||||
                    "definitions": {
 | 
			
		||||
                        "foo": {"type": 1}
 | 
			
		||||
                    }
 | 
			
		||||
                },
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										113
									
								
								tests/draft4/dependencies.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								tests/draft4/dependencies.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,113 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "dependencies",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "dependencies": {"bar": ["foo"]}
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "neither",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "nondependant",
 | 
			
		||||
                "data": {"foo": 1},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "with dependency",
 | 
			
		||||
                "data": {"foo": 1, "bar": 2},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "missing dependency",
 | 
			
		||||
                "data": {"bar": 2},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-objects",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "multiple dependencies",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "dependencies": {"quux": ["foo", "bar"]}
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "neither",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "nondependants",
 | 
			
		||||
                "data": {"foo": 1, "bar": 2},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "with dependencies",
 | 
			
		||||
                "data": {"foo": 1, "bar": 2, "quux": 3},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "missing dependency",
 | 
			
		||||
                "data": {"foo": 1, "quux": 2},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "missing other dependency",
 | 
			
		||||
                "data": {"bar": 1, "quux": 2},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "missing both dependencies",
 | 
			
		||||
                "data": {"quux": 1},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "multiple dependencies subschema",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "dependencies": {
 | 
			
		||||
                "bar": {
 | 
			
		||||
                    "properties": {
 | 
			
		||||
                        "foo": {"type": "integer"},
 | 
			
		||||
                        "bar": {"type": "integer"}
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "valid",
 | 
			
		||||
                "data": {"foo": 1, "bar": 2},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "no dependency",
 | 
			
		||||
                "data": {"foo": "quux"},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "wrong type",
 | 
			
		||||
                "data": {"foo": "quux", "bar": 2},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "wrong type other",
 | 
			
		||||
                "data": {"foo": 2, "bar": "quux"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "wrong type both",
 | 
			
		||||
                "data": {"foo": "quux", "bar": "quux"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										39
									
								
								tests/draft4/enum.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								tests/draft4/enum.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "simple enum validation",
 | 
			
		||||
        "schema": {"enum": [1, 2, 3]},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "one of the enum is valid",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "something else is invalid",
 | 
			
		||||
                "data": 4,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "heterogeneous enum validation",
 | 
			
		||||
        "schema": {"enum": [6, "foo", [], true, {"foo": 12}]},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "one of the enum is valid",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "something else is invalid",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "objects are deep compared",
 | 
			
		||||
                "data": {"foo": false},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										46
									
								
								tests/draft4/items.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								tests/draft4/items.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "a schema given for items",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "items": {"type": "integer"}
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "valid items",
 | 
			
		||||
                "data": [ 1, 2, 3 ],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "wrong type of items",
 | 
			
		||||
                "data": [1, "x"],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-arrays",
 | 
			
		||||
                "data": {"foo" : "bar"},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "an array of schemas for items",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "items": [
 | 
			
		||||
                {"type": "integer"},
 | 
			
		||||
                {"type": "string"}
 | 
			
		||||
            ]
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "correct types",
 | 
			
		||||
                "data": [ 1, "foo" ],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "wrong types",
 | 
			
		||||
                "data": [ "foo", 1 ],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										28
									
								
								tests/draft4/maxItems.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								tests/draft4/maxItems.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "maxItems validation",
 | 
			
		||||
        "schema": {"maxItems": 2},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "shorter is valid",
 | 
			
		||||
                "data": [1],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "exact length is valid",
 | 
			
		||||
                "data": [1, 2],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "too long is invalid",
 | 
			
		||||
                "data": [1, 2, 3],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-arrays",
 | 
			
		||||
                "data": "foobar",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										28
									
								
								tests/draft4/maxLength.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								tests/draft4/maxLength.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "maxLength validation",
 | 
			
		||||
        "schema": {"maxLength": 2},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "shorter is valid",
 | 
			
		||||
                "data": "f",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "exact length is valid",
 | 
			
		||||
                "data": "fo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "too long is invalid",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-strings",
 | 
			
		||||
                "data": 10,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										28
									
								
								tests/draft4/maxProperties.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								tests/draft4/maxProperties.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "maxProperties validation",
 | 
			
		||||
        "schema": {"maxProperties": 2},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "shorter is valid",
 | 
			
		||||
                "data": {"foo": 1},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "exact length is valid",
 | 
			
		||||
                "data": {"foo": 1, "bar": 2},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "too long is invalid",
 | 
			
		||||
                "data": {"foo": 1, "bar": 2, "baz": 3},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-objects",
 | 
			
		||||
                "data": "foobar",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										42
									
								
								tests/draft4/maximum.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								tests/draft4/maximum.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "maximum validation",
 | 
			
		||||
        "schema": {"maximum": 3.0},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "below the maximum is valid",
 | 
			
		||||
                "data": 2.6,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "above the maximum is invalid",
 | 
			
		||||
                "data": 3.5,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-numbers",
 | 
			
		||||
                "data": "x",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "exclusiveMaximum validation",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "maximum": 3.0,
 | 
			
		||||
            "exclusiveMaximum": true
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "below the maximum is still valid",
 | 
			
		||||
                "data": 2.2,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "boundary point is invalid",
 | 
			
		||||
                "data": 3.0,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										28
									
								
								tests/draft4/minItems.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								tests/draft4/minItems.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "minItems validation",
 | 
			
		||||
        "schema": {"minItems": 1},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "longer is valid",
 | 
			
		||||
                "data": [1, 2],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "exact length is valid",
 | 
			
		||||
                "data": [1],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "too short is invalid",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-arrays",
 | 
			
		||||
                "data": "",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										28
									
								
								tests/draft4/minLength.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								tests/draft4/minLength.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "minLength validation",
 | 
			
		||||
        "schema": {"minLength": 2},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "longer is valid",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "exact length is valid",
 | 
			
		||||
                "data": "fo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "too short is invalid",
 | 
			
		||||
                "data": "f",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-strings",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										28
									
								
								tests/draft4/minProperties.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								tests/draft4/minProperties.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "minProperties validation",
 | 
			
		||||
        "schema": {"minProperties": 1},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "longer is valid",
 | 
			
		||||
                "data": {"foo": 1, "bar": 2},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "exact length is valid",
 | 
			
		||||
                "data": {"foo": 1},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "too short is invalid",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-objects",
 | 
			
		||||
                "data": "",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										42
									
								
								tests/draft4/minimum.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								tests/draft4/minimum.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "minimum validation",
 | 
			
		||||
        "schema": {"minimum": 1.1},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "above the minimum is valid",
 | 
			
		||||
                "data": 2.6,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "below the minimum is invalid",
 | 
			
		||||
                "data": 0.6,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-numbers",
 | 
			
		||||
                "data": "x",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "exclusiveMinimum validation",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "minimum": 1.1,
 | 
			
		||||
            "exclusiveMinimum": true
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "above the minimum is still valid",
 | 
			
		||||
                "data": 1.2,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "boundary point is invalid",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										60
									
								
								tests/draft4/multipleOf.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								tests/draft4/multipleOf.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,60 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "by int",
 | 
			
		||||
        "schema": {"multipleOf": 2},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "int by int",
 | 
			
		||||
                "data": 10,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "int by int fail",
 | 
			
		||||
                "data": 7,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-numbers",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "by number",
 | 
			
		||||
        "schema": {"multipleOf": 1.5},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "zero is multiple of anything",
 | 
			
		||||
                "data": 0,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "4.5 is multiple of 1.5",
 | 
			
		||||
                "data": 4.5,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "35 is not multiple of 1.5",
 | 
			
		||||
                "data": 35,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "by small number",
 | 
			
		||||
        "schema": {"multipleOf": 0.0001},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "0.0075 is multiple of 0.0001",
 | 
			
		||||
                "data": 0.0075,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "0.00751 is not multiple of 0.0001",
 | 
			
		||||
                "data": 0.00751,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										73
									
								
								tests/draft4/not.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								tests/draft4/not.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,73 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "not",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "not": {"type": "integer"}
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "allowed",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "disallowed",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "not multiple types",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "not": {"type": ["integer", "boolean"]}
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "valid",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "other mismatch",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "not more complex schema",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "not": {
 | 
			
		||||
                "type": "object",
 | 
			
		||||
                "properties": {
 | 
			
		||||
                    "foo": {
 | 
			
		||||
                        "type": "string"
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
             }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "match",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "other match",
 | 
			
		||||
                "data": {"foo": 1},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch",
 | 
			
		||||
                "data": {"foo": "bar"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										68
									
								
								tests/draft4/oneOf.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								tests/draft4/oneOf.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,68 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "oneOf",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "oneOf": [
 | 
			
		||||
                {
 | 
			
		||||
                    "type": "integer"
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "minimum": 2
 | 
			
		||||
                }
 | 
			
		||||
            ]
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "first oneOf valid",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "second oneOf valid",
 | 
			
		||||
                "data": 2.5,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "both oneOf valid",
 | 
			
		||||
                "data": 3,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "neither oneOf valid",
 | 
			
		||||
                "data": 1.5,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "oneOf with base schema",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "type": "string",
 | 
			
		||||
            "oneOf" : [
 | 
			
		||||
                {
 | 
			
		||||
                    "minLength": 2
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "maxLength": 4
 | 
			
		||||
                }
 | 
			
		||||
            ]
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch base schema",
 | 
			
		||||
                "data": 3,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "one oneOf valid",
 | 
			
		||||
                "data": "foobar",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "both oneOf valid",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										49
									
								
								tests/draft4/optional/bignum.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								tests/draft4/optional/bignum.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "integer",
 | 
			
		||||
        "schema": {"type": "integer"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a bignum is an integer",
 | 
			
		||||
                "data": 12345678910111213141516171819202122232425262728293031,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "number",
 | 
			
		||||
        "schema": {"type": "number"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a bignum is a number",
 | 
			
		||||
                "data": 98249283749234923498293171823948729348710298301928331,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "string",
 | 
			
		||||
        "schema": {"type": "string"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a bignum is not a string",
 | 
			
		||||
                "data": 98249283749234923498293171823948729348710298301928331,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "float comparison with high precision",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "maximum": 972783798187987123879878123.18878137,
 | 
			
		||||
            "exclusiveMaximum": true
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "comparison works for high numbers",
 | 
			
		||||
                "data": 972783798187987123879878123.188781371,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										123
									
								
								tests/draft4/optional/format.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										123
									
								
								tests/draft4/optional/format.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,123 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "validation of date-time strings",
 | 
			
		||||
        "schema": {"format": "date-time"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid date-time string",
 | 
			
		||||
                "data": "1963-06-19T08:30:06.283185Z",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an invalid date-time string",
 | 
			
		||||
                "data": "06/19/1963 08:30:06 PST",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "validation of URIs",
 | 
			
		||||
        "schema": {"format": "uri"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid URI",
 | 
			
		||||
                "data": "http://foo.bar/?baz=qux#quux",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an invalid URI",
 | 
			
		||||
                "data": "\\\\WINDOWS\\fileshare",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "validation of e-mail addresses",
 | 
			
		||||
        "schema": {"format": "email"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid e-mail address",
 | 
			
		||||
                "data": "joe.bloggs@example.com",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an invalid e-mail address",
 | 
			
		||||
                "data": "2962",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "validation of IP addresses",
 | 
			
		||||
        "schema": {"format": "ipv4"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid IP address",
 | 
			
		||||
                "data": "192.168.0.1",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an IP address with too many components",
 | 
			
		||||
                "data": "127.0.0.0.1",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an IP address with out-of-range values",
 | 
			
		||||
                "data": "256.256.256.256",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "validation of IPv6 addresses",
 | 
			
		||||
        "schema": {"format": "ipv6"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid IPv6 address",
 | 
			
		||||
                "data": "::1",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an IPv6 address with out-of-range values",
 | 
			
		||||
                "data": "12345::",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an IPv6 address with too many components",
 | 
			
		||||
                "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an IPv6 address containing illegal characters",
 | 
			
		||||
                "data": "::laptop",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "validation of host names",
 | 
			
		||||
        "schema": {"format": "hostname"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a valid host name",
 | 
			
		||||
                "data": "www.example.com",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a host name starting with an illegal character",
 | 
			
		||||
                "data": "-a-host-name-that-starts-with--",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a host name containing illegal characters",
 | 
			
		||||
                "data": "not_a_valid_host_name",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a host name with a component too long",
 | 
			
		||||
                "data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										15
									
								
								tests/draft4/optional/zeroTerminatedFloats.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								tests/draft4/optional/zeroTerminatedFloats.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "some languages do not distinguish between different types of numeric value",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "type": "integer"
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is not an integer even without fractional part",
 | 
			
		||||
                "data": 1.0,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										23
									
								
								tests/draft4/pattern.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								tests/draft4/pattern.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "pattern validation",
 | 
			
		||||
        "schema": {"pattern": "^a*$"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a matching pattern is valid",
 | 
			
		||||
                "data": "aaa",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a non-matching pattern is invalid",
 | 
			
		||||
                "data": "abc",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-strings",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										110
									
								
								tests/draft4/patternProperties.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								tests/draft4/patternProperties.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,110 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description":
 | 
			
		||||
            "patternProperties validates properties matching a regex",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "patternProperties": {
 | 
			
		||||
                "f.*o": {"type": "integer"}
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a single valid match is valid",
 | 
			
		||||
                "data": {"foo": 1},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "multiple valid matches is valid",
 | 
			
		||||
                "data": {"foo": 1, "foooooo" : 2},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a single invalid match is invalid",
 | 
			
		||||
                "data": {"foo": "bar", "fooooo": 2},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "multiple invalid matches is invalid",
 | 
			
		||||
                "data": {"foo": "bar", "foooooo" : "baz"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-objects",
 | 
			
		||||
                "data": 12,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "multiple simultaneous patternProperties are validated",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "patternProperties": {
 | 
			
		||||
                "a*": {"type": "integer"},
 | 
			
		||||
                "aaa*": {"maximum": 20}
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a single valid match is valid",
 | 
			
		||||
                "data": {"a": 21},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a simultaneous match is valid",
 | 
			
		||||
                "data": {"aaaa": 18},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "multiple matches is valid",
 | 
			
		||||
                "data": {"a": 21, "aaaa": 18},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an invalid due to one is invalid",
 | 
			
		||||
                "data": {"a": "bar"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an invalid due to the other is invalid",
 | 
			
		||||
                "data": {"aaaa": 31},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an invalid due to both is invalid",
 | 
			
		||||
                "data": {"aaa": "foo", "aaaa": 31},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "regexes are not anchored by default and are case sensitive",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "patternProperties": {
 | 
			
		||||
                "[0-9]{2,}": { "type": "boolean" },
 | 
			
		||||
                "X_": { "type": "string" }
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "non recognized members are ignored",
 | 
			
		||||
                "data": { "answer 1": "42" },
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "recognized members are accounted for",
 | 
			
		||||
                "data": { "a31b": null },
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "regexes are case sensitive",
 | 
			
		||||
                "data": { "a_x_3": 3 },
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "regexes are case sensitive, 2",
 | 
			
		||||
                "data": { "a_X_3": 3 },
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										92
									
								
								tests/draft4/properties.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								tests/draft4/properties.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,92 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "object properties validation",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {
 | 
			
		||||
                "foo": {"type": "integer"},
 | 
			
		||||
                "bar": {"type": "string"}
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "both properties present and valid is valid",
 | 
			
		||||
                "data": {"foo": 1, "bar": "baz"},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "one property invalid is invalid",
 | 
			
		||||
                "data": {"foo": 1, "bar": {}},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "both properties invalid is invalid",
 | 
			
		||||
                "data": {"foo": [], "bar": {}},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "doesn't invalidate other properties",
 | 
			
		||||
                "data": {"quux": []},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ignores non-objects",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description":
 | 
			
		||||
            "properties, patternProperties, additionalProperties interaction",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {
 | 
			
		||||
                "foo": {"type": "array", "maxItems": 3},
 | 
			
		||||
                "bar": {"type": "array"}
 | 
			
		||||
            },
 | 
			
		||||
            "patternProperties": {"f.o": {"minItems": 2}},
 | 
			
		||||
            "additionalProperties": {"type": "integer"}
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "property validates property",
 | 
			
		||||
                "data": {"foo": [1, 2]},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "property invalidates property",
 | 
			
		||||
                "data": {"foo": [1, 2, 3, 4]},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "patternProperty invalidates property",
 | 
			
		||||
                "data": {"foo": []},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "patternProperty validates nonproperty",
 | 
			
		||||
                "data": {"fxo": [1, 2]},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "patternProperty invalidates nonproperty",
 | 
			
		||||
                "data": {"fxo": []},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "additionalProperty ignores property",
 | 
			
		||||
                "data": {"bar": []},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "additionalProperty validates others",
 | 
			
		||||
                "data": {"quux": 3},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "additionalProperty invalidates others",
 | 
			
		||||
                "data": {"quux": "foo"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										123
									
								
								tests/draft4/ref.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										123
									
								
								tests/draft4/ref.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,123 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "root pointer ref",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {
 | 
			
		||||
                "foo": {"$ref": "#"}
 | 
			
		||||
            },
 | 
			
		||||
            "additionalProperties": false
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "match",
 | 
			
		||||
                "data": {"foo": false},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "recursive match",
 | 
			
		||||
                "data": {"foo": {"foo": false}},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch",
 | 
			
		||||
                "data": {"bar": false},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "recursive mismatch",
 | 
			
		||||
                "data": {"foo": {"bar": false}},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "relative pointer ref",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {
 | 
			
		||||
                "foo": {"type": "integer"},
 | 
			
		||||
                "bar": {"$ref": "#/properties/foo"}
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "match",
 | 
			
		||||
                "data": {"bar": 3},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "mismatch",
 | 
			
		||||
                "data": {"bar": true},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "escaped pointer ref",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "tilda~field": {"type": "integer"},
 | 
			
		||||
            "slash/field": {"type": "integer"},
 | 
			
		||||
            "percent%field": {"type": "integer"},
 | 
			
		||||
            "properties": {
 | 
			
		||||
                "tilda": {"$ref": "#/tilda~0field"},
 | 
			
		||||
                "slash": {"$ref": "#/slash~1field"},
 | 
			
		||||
                "percent": {"$ref": "#/percent%25field"}
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "slash",
 | 
			
		||||
                "data": {"slash": "aoeu"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "tilda",
 | 
			
		||||
                "data": {"tilda": "aoeu"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "percent",
 | 
			
		||||
                "data": {"percent": "aoeu"},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "nested refs",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "definitions": {
 | 
			
		||||
                "a": {"type": "integer"},
 | 
			
		||||
                "b": {"$ref": "#/definitions/a"},
 | 
			
		||||
                "c": {"$ref": "#/definitions/b"}
 | 
			
		||||
            },
 | 
			
		||||
            "$ref": "#/definitions/c"
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "nested ref valid",
 | 
			
		||||
                "data": 5,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "nested ref invalid",
 | 
			
		||||
                "data": "a",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "remote ref, containing refs itself",
 | 
			
		||||
        "schema": {"$ref": "http://json-schema.org/draft-04/schema#"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "remote ref valid",
 | 
			
		||||
                "data": {"minLength": 1},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "remote ref invalid",
 | 
			
		||||
                "data": {"minLength": -1},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										74
									
								
								tests/draft4/refRemote.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								tests/draft4/refRemote.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,74 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "remote ref",
 | 
			
		||||
        "schema": {"$ref": "http://localhost:1234/integer.json"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "remote ref valid",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "remote ref invalid",
 | 
			
		||||
                "data": "a",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "fragment within remote ref",
 | 
			
		||||
        "schema": {"$ref": "http://localhost:1234/subSchemas.json#/integer"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "remote fragment valid",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "remote fragment invalid",
 | 
			
		||||
                "data": "a",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "ref within remote ref",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "$ref": "http://localhost:1234/subSchemas.json#/refToInteger"
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ref within ref valid",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "ref within ref invalid",
 | 
			
		||||
                "data": "a",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "change resolution scope",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "id": "http://localhost:1234/",
 | 
			
		||||
            "items": {
 | 
			
		||||
                "id": "folder/",
 | 
			
		||||
                "items": {"$ref": "folderInteger.json"}
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "changed scope ref valid",
 | 
			
		||||
                "data": [[1]],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "changed scope ref invalid",
 | 
			
		||||
                "data": [["a"]],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										39
									
								
								tests/draft4/required.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								tests/draft4/required.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "required validation",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {
 | 
			
		||||
                "foo": {},
 | 
			
		||||
                "bar": {}
 | 
			
		||||
            },
 | 
			
		||||
            "required": ["foo"]
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "present required property is valid",
 | 
			
		||||
                "data": {"foo": 1},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "non-present required property is invalid",
 | 
			
		||||
                "data": {"bar": 1},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "required default validation",
 | 
			
		||||
        "schema": {
 | 
			
		||||
            "properties": {
 | 
			
		||||
                "foo": {}
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "not required by default",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										330
									
								
								tests/draft4/type.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										330
									
								
								tests/draft4/type.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,330 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "integer type matches integers",
 | 
			
		||||
        "schema": {"type": "integer"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an integer is an integer",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is not an integer",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is not an integer",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is not an integer",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is not an integer",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a boolean is not an integer",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "null is not an integer",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "number type matches numbers",
 | 
			
		||||
        "schema": {"type": "number"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an integer is a number",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is a number",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is not a number",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is not a number",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is not a number",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a boolean is not a number",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "null is not a number",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "string type matches strings",
 | 
			
		||||
        "schema": {"type": "string"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "1 is not a string",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is not a string",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is a string",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is not a string",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is not a string",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a boolean is not a string",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "null is not a string",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "object type matches objects",
 | 
			
		||||
        "schema": {"type": "object"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an integer is not an object",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is not an object",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is not an object",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is an object",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is not an object",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a boolean is not an object",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "null is not an object",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "array type matches arrays",
 | 
			
		||||
        "schema": {"type": "array"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an integer is not an array",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is not an array",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is not an array",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is not an array",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is not an array",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a boolean is not an array",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "null is not an array",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "boolean type matches booleans",
 | 
			
		||||
        "schema": {"type": "boolean"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an integer is not a boolean",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is not a boolean",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is not a boolean",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is not a boolean",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is not a boolean",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a boolean is not a boolean",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "null is not a boolean",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "null type matches only the null object",
 | 
			
		||||
        "schema": {"type": "null"},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an integer is not null",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is not null",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is not null",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is not null",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is not null",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a boolean is not null",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "null is null",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "description": "multiple types can be specified in an array",
 | 
			
		||||
        "schema": {"type": ["integer", "string"]},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an integer is valid",
 | 
			
		||||
                "data": 1,
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a string is valid",
 | 
			
		||||
                "data": "foo",
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a float is invalid",
 | 
			
		||||
                "data": 1.1,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an object is invalid",
 | 
			
		||||
                "data": {},
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "an array is invalid",
 | 
			
		||||
                "data": [],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "a boolean is invalid",
 | 
			
		||||
                "data": true,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "null is invalid",
 | 
			
		||||
                "data": null,
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
							
								
								
									
										79
									
								
								tests/draft4/uniqueItems.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								tests/draft4/uniqueItems.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,79 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "description": "uniqueItems validation",
 | 
			
		||||
        "schema": {"uniqueItems": true},
 | 
			
		||||
        "tests": [
 | 
			
		||||
            {
 | 
			
		||||
                "description": "unique array of integers is valid",
 | 
			
		||||
                "data": [1, 2],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "non-unique array of integers is invalid",
 | 
			
		||||
                "data": [1, 1],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "numbers are unique if mathematically unequal",
 | 
			
		||||
                "data": [1.0, 1.00, 1],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "unique array of objects is valid",
 | 
			
		||||
                "data": [{"foo": "bar"}, {"foo": "baz"}],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "non-unique array of objects is invalid",
 | 
			
		||||
                "data": [{"foo": "bar"}, {"foo": "bar"}],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "unique array of nested objects is valid",
 | 
			
		||||
                "data": [
 | 
			
		||||
                    {"foo": {"bar" : {"baz" : true}}},
 | 
			
		||||
                    {"foo": {"bar" : {"baz" : false}}}
 | 
			
		||||
                ],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "non-unique array of nested objects is invalid",
 | 
			
		||||
                "data": [
 | 
			
		||||
                    {"foo": {"bar" : {"baz" : true}}},
 | 
			
		||||
                    {"foo": {"bar" : {"baz" : true}}}
 | 
			
		||||
                ],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "unique array of arrays is valid",
 | 
			
		||||
                "data": [["foo"], ["bar"]],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "non-unique array of arrays is invalid",
 | 
			
		||||
                "data": [["foo"], ["foo"]],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "1 and true are unique",
 | 
			
		||||
                "data": [1, true],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "0 and false are unique",
 | 
			
		||||
                "data": [0, false],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "unique heterogeneous types are valid",
 | 
			
		||||
                "data": [{}, [1], true, null, 1],
 | 
			
		||||
                "valid": true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "description": "non-unique heterogeneous types are invalid",
 | 
			
		||||
                "data": [{}, [1], true, null, {}, 1],
 | 
			
		||||
                "valid": false
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
		Reference in New Issue
	
	Block a user