The jsonschema package is part of of the API of the mcp package, so it should not be internal. Change-Id: I9520797837329fc2cda09c2f46ec4d48d031b9d3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/669996 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com>
102 lines
3 KiB
JSON
102 lines
3 KiB
JSON
[
|
|
{
|
|
"description": "maxContains without contains is ignored",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/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": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/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": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/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": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/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
|
|
}
|
|
]
|
|
}
|
|
]
|