-
-
Notifications
You must be signed in to change notification settings - Fork 886
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patternGroups keyword (v5 proposals)
- Loading branch information
1 parent
cf35958
commit 7d96e1b
Showing
11 changed files
with
529 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
|
||
var jsonSchemaTest = require('json-schema-test') | ||
, getAjvInstances = require('./ajv_instances'); | ||
|
||
var isBrowser = typeof window == 'object'; | ||
|
||
var fullTest = isBrowser || !process.env.AJV_FAST_TEST; | ||
var instances = getAjvInstances(fullTest ? { | ||
beautify: true, | ||
allErrors: true, | ||
verbose: true, | ||
format: 'full', | ||
inlineRefs: false, | ||
jsonPointers: true, | ||
} : { allErrors: true }, { v5: true }); | ||
|
||
|
||
jsonSchemaTest(instances, { | ||
description: 'v5 schemas tests of ' + instances.length + ' ajv instances with different options', | ||
suites: testSuites(), | ||
afterError: function (res) { | ||
console.log('ajv options:', res.validator.opts); | ||
}, | ||
cwd: __dirname, | ||
hideFolder: 'v5/', | ||
timeout: 90000 | ||
}); | ||
|
||
|
||
function testSuites() { | ||
if (typeof window == 'object') { | ||
var suites = { | ||
'v5 proposals': require('./v5/{**/,}*.json', {mode: 'list'}) | ||
}; | ||
for (var suiteName in suites) { | ||
suites[suiteName].forEach(function (suite) { | ||
suite.test = suite.module; | ||
}); | ||
} | ||
} else { | ||
var suites = { | ||
'v5 proposals': './v5/{**/,}*.json' | ||
} | ||
} | ||
return suites; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
[ | ||
{ | ||
"description": "constant keyword requires the value to be equal to some constant", | ||
"schema": { "constant": 2 }, | ||
"tests": [ | ||
{ | ||
"description": "same value is valid", | ||
"data": 2, | ||
"valid": true | ||
}, | ||
{ | ||
"description": "another value is invalid", | ||
"data": 5, | ||
"valid": false | ||
}, | ||
{ | ||
"description": "another type is invalid", | ||
"data": "a", | ||
"valid": false | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "constant keyword requires the value to be equal to some object", | ||
"schema": { "constant": { "foo": "bar", "baz": "bax" } }, | ||
"tests": [ | ||
{ | ||
"description": "same object is valid", | ||
"data": { "foo": "bar", "baz": "bax" }, | ||
"valid": true | ||
}, | ||
{ | ||
"description": "same object with different property order is valid", | ||
"data": { "baz": "bax", "foo": "bar" }, | ||
"valid": true | ||
}, | ||
{ | ||
"description": "another object is invalid", | ||
"data": { "foo": "bar" }, | ||
"valid": false | ||
}, | ||
{ | ||
"description": "another type is invalid", | ||
"data": [ 1, 2 ], | ||
"valid": false | ||
} | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
[ | ||
{ | ||
"description": "contains keyword requires the item matching schema to be present", | ||
"schema": { | ||
"contains": { "minimum": 5 } | ||
}, | ||
"tests": [ | ||
{ | ||
"description": "array with item matching schema (5) is valid", | ||
"data": [3, 4, 5], | ||
"valid": true | ||
}, | ||
{ | ||
"description": "array with item matching schema (6) is valid", | ||
"data": [3, 4, 6], | ||
"valid": true | ||
}, | ||
{ | ||
"description": "array without item matching schema is invalid", | ||
"data": [1, 2, 3, 4], | ||
"valid": false | ||
}, | ||
{ | ||
"skip": true, | ||
"description": "not array is valid", | ||
"data": {}, | ||
"valid": true | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "contains keyword with constant keyword requires a specific item to be present", | ||
"schema": { | ||
"contains": { "constant": 5 } | ||
}, | ||
"tests": [ | ||
{ | ||
"description": "array with item 5 is valid", | ||
"data": [3, 4, 5], | ||
"valid": true | ||
}, | ||
{ | ||
"description": "array without item 5 is invalid", | ||
"data": [1, 2, 3, 4], | ||
"valid": false | ||
} | ||
] | ||
} | ||
] |
Oops, something went wrong.