- Rename fixtures/items.json to fixtures/array.json to better reflect array testing constraints. - Update reference paths in src/tests/fixtures.rs and across other fixture JSON files. - Remove unused HashMap import in src/validator/rules/dict.rs to resolve the compiler warning.
174 lines
3.5 KiB
JSON
174 lines
3.5 KiB
JSON
[
|
|
{
|
|
"description": "maxItems validation",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "maxItems_0_0",
|
|
"schemas": {
|
|
"maxItems_0_0": {
|
|
"maxItems": 2
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "shorter is valid",
|
|
"data": [
|
|
1
|
|
],
|
|
"schema_id": "maxItems_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "exact length is valid",
|
|
"data": [
|
|
1,
|
|
2
|
|
],
|
|
"schema_id": "maxItems_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "too long is invalid",
|
|
"data": [
|
|
1,
|
|
2,
|
|
3
|
|
],
|
|
"schema_id": "maxItems_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "MAX_ITEMS_VIOLATED",
|
|
"values": {
|
|
"limit": "2",
|
|
"count": "3"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "maxItems_0_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "ignores non-arrays",
|
|
"data": "foobar",
|
|
"schema_id": "maxItems_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "maxItems validation with a decimal",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "maxItems_1_0",
|
|
"schemas": {
|
|
"maxItems_1_0": {
|
|
"maxItems": 2
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "shorter is valid",
|
|
"data": [
|
|
1
|
|
],
|
|
"schema_id": "maxItems_1_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "too long is invalid",
|
|
"data": [
|
|
1,
|
|
2,
|
|
3
|
|
],
|
|
"schema_id": "maxItems_1_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "MAX_ITEMS_VIOLATED",
|
|
"values": {
|
|
"count": "3",
|
|
"limit": "2"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "maxItems_1_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "extensible: true allows extra items in maxItems (but counted)",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "maxItems_2_0",
|
|
"schemas": {
|
|
"maxItems_2_0": {
|
|
"maxItems": 2
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "extra item counted towards maxItems",
|
|
"data": [
|
|
1,
|
|
2,
|
|
3
|
|
],
|
|
"schema_id": "maxItems_2_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "MAX_ITEMS_VIOLATED",
|
|
"values": {
|
|
"count": "3",
|
|
"limit": "2"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "maxItems_2_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
] |