ajv/spec/tests/rules/format.json

271 lines
6.2 KiB
JSON

[
{
"description": "whitelisted unknown format is valid",
"schema": {
"format": "allowedUnknown"
},
"tests": [
{
"description": "any string is valid",
"data": "any value",
"valid": true
}
]
},
{
"description": "format: regex",
"schema": {
"format": "regex"
},
"tests": [
{
"description": "valid regex",
"data": "[0-9]",
"valid": true
},
{
"description": "invalid regex",
"data": "[9-0]",
"valid": false
},
{
"description": "not string is valid",
"data": 123,
"valid": true
}
]
},
{
"description": "format: uri",
"schema": {
"format": "uri"
},
"tests": [
{
"description": "valid uri",
"data": "urn:isbn:978-3-531-18621-4",
"valid": true
},
{
"description": "valid relative uri",
"data": "/abc",
"valid": true
}
]
},
{
"description": "format: hostname",
"schema": {
"format": "hostname"
},
"tests": [
{
"description": "valid hostname",
"data": "123.example.com",
"valid": true
},
{
"description": "valid hostname #312",
"data": "lead-routing-qa.lvuucj.0001.use1.cache.amazonaws.com",
"valid": true
}
]
},
{
"description": "validation of date strings",
"schema": {"format": "date"},
"tests": [
{
"description": "a valid date string",
"data": "1963-06-19",
"valid": true
},
{
"description": "an invalid date string",
"data": "06/19/1963",
"valid": false
},
{
"description": "only RFC3339 not all of ISO 8601 are valid",
"data": "2013-350",
"valid": false
}
]
},
{
"description": "validation of time strings",
"schema": {"format": "time"},
"tests": [
{
"description": "a valid time",
"data": "12:34:56",
"valid": true
},
{
"description": "a valid time with milliseconds",
"data": "12:34:56.789",
"valid": true
},
{
"description": "a valid time with timezone",
"data": "12:34:56+01:00",
"valid": true
},
{
"description": "not valid time",
"data": "12.34.56",
"valid": false
}
]
},
{
"description": "validation of date-time strings",
"schema": {"format": "date-time"},
"tests": [
{
"description": "a valid date-time string",
"data": "1963-06-19T12:13:14Z",
"valid": true
},
{
"description": "an invalid date-time string (no time)",
"data": "1963-06-19",
"valid": false
},
{
"description": "an invalid date-time string (additional part)",
"data": "1963-06-19T12:13:14ZTinvalid",
"valid": false
}
]
},
{
"description": "validation of uuid strings",
"schema": {"format": "uuid"},
"tests": [
{
"description": "a valid uuid",
"data": "f81d4fae-7dec-11d0-a765-00a0c91e6bf6",
"valid": true
},
{
"description": "a valid uuid with uri prefix",
"data": "urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6",
"valid": true
},
{
"description": "not valid uuid",
"data": "f81d4fae7dec11d0a76500a0c91e6bf6",
"valid": false
}
]
},
{
"description": "validation of JSON-pointer strings",
"schema": {"format": "json-pointer"},
"tests": [
{
"description": "a valid JSON-pointer",
"data": "/foo/bar~0/baz~1/%a",
"valid": true
},
{
"description": "a valid JSON-pointer as uri fragment",
"data": "#/foo/%25a",
"valid": true
},
{
"description": "empty string is valid",
"data": "",
"valid": true
},
{
"description": "/ is valid",
"data": "/",
"valid": true
},
{
"description": "not a valid JSON-pointer (~ not escaped)",
"data": "/foo/bar~",
"valid": false
},
{
"description": "not a valid JSON-pointer as uri fragment (% not URL-encoded)",
"data": "#/foo/%a",
"valid": false
},
{
"description": "valid JSON-pointer with empty segment",
"data": "/foo//bar",
"valid": true
},
{
"description": "valid JSON-pointer with the last empty segment",
"data": "/foo/bar/",
"valid": true
},
{
"description": "valid JSON-pointer with empty segment as uri fragment",
"data": "#/foo//bar",
"valid": true
},
{
"description": "valid JSON-pointer with the last empty segment as uri fragment",
"data": "#/foo/bar/",
"valid": true
}
]
},
{
"description": "validation of relative JSON-pointer strings",
"schema": {"format": "relative-json-pointer"},
"tests": [
{
"description": "a valid relative JSON-pointer",
"data": "1/foo/bar~0/baz~1/%a",
"valid": true
},
{
"description": "a valid relative JSON-pointer with #",
"data": "2#",
"valid": true
},
{
"description": "parent reference is valid",
"data": "1",
"valid": true
},
{
"description": "empty string is invalid",
"data": "",
"valid": false
},
{
"description": "not a valid relative JSON-pointer (~ not escaped)",
"data": "1/foo/bar~",
"valid": false
},
{
"description": "not a valid relative JSON-pointer (leading 0)",
"data": "01/foo",
"valid": false
},
{
"description": "not a valid relative JSON-pointer with # (leading 0)",
"data": "02#",
"valid": false
},
{
"description": "valid relative JSON-pointer with empty segment",
"data": "1/foo//bar",
"valid": true
},
{
"description": "valid relative JSON-pointer with the last empty segment",
"data": "1/foo/bar/",
"valid": true
}
]
}
]