Files
jspg/tests/fixtures/emptyString.json
2026-02-17 17:41:54 -05:00

119 lines
3.3 KiB
JSON

[
{
"description": "empty string is valid for all types (except const)",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"obj": {
"type": "object"
},
"arr": {
"type": "array"
},
"str": {
"type": "string"
},
"int": {
"type": "integer"
},
"num": {
"type": "number"
},
"bool": {
"type": "boolean"
},
"nul": {
"type": "null"
},
"fmt": {
"type": "string",
"format": "uuid"
},
"con": {
"const": "value"
},
"con_empty": {
"const": ""
}
}
},
"tests": [
{
"description": "empty string valid for object",
"data": {
"obj": ""
},
"valid": true
},
{
"description": "empty string valid for array",
"data": {
"arr": ""
},
"valid": true
},
{
"description": "empty string valid for string",
"data": {
"str": ""
},
"valid": true
},
{
"description": "empty string valid for integer",
"data": {
"int": ""
},
"valid": true
},
{
"description": "empty string valid for number",
"data": {
"num": ""
},
"valid": true
},
{
"description": "empty string valid for boolean",
"data": {
"bool": ""
},
"valid": true
},
{
"description": "empty string valid for null",
"data": {
"nul": ""
},
"valid": true
},
{
"description": "empty string valid for format",
"data": {
"fmt": ""
},
"valid": true
},
{
"description": "empty string INVALID for const (unless const is empty string)",
"data": {
"con": ""
},
"valid": false,
"expect_errors": [
{
"code": "CONST_VIOLATED",
"path": "/con"
}
]
},
{
"description": "empty string VALID for const if const IS empty string",
"data": {
"con_empty": ""
},
"valid": true
}
]
}
]