summaryrefslogtreecommitdiff
path: root/tests/draft2020-12/maxContains.json
diff options
context:
space:
mode:
Diffstat (limited to 'tests/draft2020-12/maxContains.json')
-rw-r--r--tests/draft2020-12/maxContains.json98
1 files changed, 98 insertions, 0 deletions
diff --git a/tests/draft2020-12/maxContains.json b/tests/draft2020-12/maxContains.json
new file mode 100644
index 0000000..61c967d
--- /dev/null
+++ b/tests/draft2020-12/maxContains.json
@@ -0,0 +1,98 @@
+[
+ {
+ "description": "maxContains without contains is ignored",
+ "schema": {
+ "maxContains": 1
+ },
+ "tests": [
+ {
+ "description": "one item valid against lone maxContains",
+ "data": [ 1 ],
+ "valid": true
+ },
+ {
+ "description": "two items still valid against lone maxContains",
+ "data": [ 1, 2 ],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "maxContains with contains",
+ "schema": {
+ "contains": {"const": 1},
+ "maxContains": 1
+ },
+ "tests": [
+ {
+ "description": "empty data",
+ "data": [ ],
+ "valid": false
+ },
+ {
+ "description": "all elements match, valid maxContains",
+ "data": [ 1 ],
+ "valid": true
+ },
+ {
+ "description": "all elements match, invalid maxContains",
+ "data": [ 1, 1 ],
+ "valid": false
+ },
+ {
+ "description": "some elements match, valid maxContains",
+ "data": [ 1, 2 ],
+ "valid": true
+ },
+ {
+ "description": "some elements match, invalid maxContains",
+ "data": [ 1, 2, 1 ],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "maxContains with contains, value with a decimal",
+ "schema": {
+ "contains": {"const": 1},
+ "maxContains": 1.0
+ },
+ "tests": [
+ {
+ "description": "one element matches, valid maxContains",
+ "data": [ 1 ],
+ "valid": true
+ },
+ {
+ "description": "too many elements match, invalid maxContains",
+ "data": [ 1, 1 ],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "minContains < maxContains",
+ "schema": {
+ "contains": {"const": 1},
+ "minContains": 1,
+ "maxContains": 3
+ },
+ "tests": [
+ {
+ "description": "actual < minContains < maxContains",
+ "data": [ ],
+ "valid": false
+ },
+ {
+ "description": "minContains < actual < maxContains",
+ "data": [ 1, 1 ],
+ "valid": true
+ },
+ {
+ "description": "minContains < maxContains < actual",
+ "data": [ 1, 1, 1, 1 ],
+ "valid": false
+ }
+ ]
+ }
+]