Add validation for JSON objects (Go maps). The map keys are called "properties." As with arrays, annotations are needed to support the unevaluatedProperties keyword. Change-Id: Ia01f74300f4bcdbce94065572d83c46dfaa53ae7 Reviewed-on: https://go-review.googlesource.com/c/tools/+/668256 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
60 lines
1.6 KiB
JSON
60 lines
1.6 KiB
JSON
[
|
|
{
|
|
"description": "minProperties validation",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/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 arrays",
|
|
"data": [],
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "ignores strings",
|
|
"data": "",
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "ignores other non-objects",
|
|
"data": 12,
|
|
"valid": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "minProperties validation with a decimal",
|
|
"schema": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"minProperties": 1.0
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "longer is valid",
|
|
"data": {"foo": 1, "bar": 2},
|
|
"valid": true
|
|
},
|
|
{
|
|
"description": "too short is invalid",
|
|
"data": {},
|
|
"valid": false
|
|
}
|
|
]
|
|
}
|
|
]
|