- 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.
1326 lines
29 KiB
JSON
1326 lines
29 KiB
JSON
[
|
|
{
|
|
"description": "const validation",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_0_0",
|
|
"schemas": {
|
|
"const_0_0": {
|
|
"const": 2
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "same value is valid",
|
|
"data": 2,
|
|
"schema_id": "const_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "another value is invalid",
|
|
"data": 5,
|
|
"schema_id": "const_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Number(2)"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_0_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "another type is invalid",
|
|
"data": "a",
|
|
"schema_id": "const_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Number(2)"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_0_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "const with object",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_1_0",
|
|
"schemas": {
|
|
"const_1_0": {
|
|
"const": {
|
|
"foo": "bar",
|
|
"baz": "bax"
|
|
},
|
|
"properties": {
|
|
"foo": {},
|
|
"baz": {}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "same object is valid",
|
|
"data": {
|
|
"foo": "bar",
|
|
"baz": "bax"
|
|
},
|
|
"schema_id": "const_1_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "same object with different property order is valid",
|
|
"data": {
|
|
"baz": "bax",
|
|
"foo": "bar"
|
|
},
|
|
"schema_id": "const_1_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "another object is invalid",
|
|
"data": {
|
|
"foo": "bar"
|
|
},
|
|
"schema_id": "const_1_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Object {\"foo\": String(\"bar\"), \"baz\": String(\"bax\")}"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_1_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "another type is invalid",
|
|
"data": [
|
|
1,
|
|
2
|
|
],
|
|
"schema_id": "const_1_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Object {\"foo\": String(\"bar\"), \"baz\": String(\"bax\")}"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_1_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "const with array",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_2_0",
|
|
"schemas": {
|
|
"const_2_0": {
|
|
"const": [
|
|
{
|
|
"foo": "bar"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "same array is valid",
|
|
"data": [
|
|
{
|
|
"foo": "bar"
|
|
}
|
|
],
|
|
"schema_id": "const_2_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "another array item is invalid",
|
|
"data": [
|
|
2
|
|
],
|
|
"schema_id": "const_2_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Array [Object {\"foo\": String(\"bar\")}]"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_2_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "array with additional items is invalid",
|
|
"data": [
|
|
1,
|
|
2,
|
|
3
|
|
],
|
|
"schema_id": "const_2_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Array [Object {\"foo\": String(\"bar\")}]"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_2_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "const with null",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_3_0",
|
|
"schemas": {
|
|
"const_3_0": {
|
|
"const": null
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "null is valid",
|
|
"data": null,
|
|
"schema_id": "const_3_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "not null is invalid",
|
|
"data": 0,
|
|
"schema_id": "const_3_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Null"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_3_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "const with false does not match 0",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_4_0",
|
|
"schemas": {
|
|
"const_4_0": {
|
|
"const": false
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "false is valid",
|
|
"data": false,
|
|
"schema_id": "const_4_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "integer zero is invalid",
|
|
"data": 0,
|
|
"schema_id": "const_4_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Bool(false)"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_4_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "float zero is invalid",
|
|
"data": 0,
|
|
"schema_id": "const_4_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Bool(false)"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_4_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "const with true does not match 1",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_5_0",
|
|
"schemas": {
|
|
"const_5_0": {
|
|
"const": true
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "true is valid",
|
|
"data": true,
|
|
"schema_id": "const_5_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "integer one is invalid",
|
|
"data": 1,
|
|
"schema_id": "const_5_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Bool(true)"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_5_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "float one is invalid",
|
|
"data": 1,
|
|
"schema_id": "const_5_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Bool(true)"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_5_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "const with [false] does not match [0]",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_6_0",
|
|
"schemas": {
|
|
"const_6_0": {
|
|
"const": [
|
|
false
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "[false] is valid",
|
|
"data": [
|
|
false
|
|
],
|
|
"schema_id": "const_6_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "[0] is invalid",
|
|
"data": [
|
|
0
|
|
],
|
|
"schema_id": "const_6_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Array [Bool(false)]"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_6_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "[0.0] is invalid",
|
|
"data": [
|
|
0
|
|
],
|
|
"schema_id": "const_6_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Array [Bool(false)]"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_6_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "const with [true] does not match [1]",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_7_0",
|
|
"schemas": {
|
|
"const_7_0": {
|
|
"const": [
|
|
true
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "[true] is valid",
|
|
"data": [
|
|
true
|
|
],
|
|
"schema_id": "const_7_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "[1] is invalid",
|
|
"data": [
|
|
1
|
|
],
|
|
"schema_id": "const_7_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Array [Bool(true)]"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_7_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "[1.0] is invalid",
|
|
"data": [
|
|
1
|
|
],
|
|
"schema_id": "const_7_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Array [Bool(true)]"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_7_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "const with {\"a\": false} does not match {\"a\": 0}",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_8_0",
|
|
"schemas": {
|
|
"const_8_0": {
|
|
"const": {
|
|
"a": false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "{\"a\": false} is valid",
|
|
"data": {
|
|
"a": false
|
|
},
|
|
"schema_id": "const_8_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "{\"a\": 0} is invalid",
|
|
"data": {
|
|
"a": 0
|
|
},
|
|
"schema_id": "const_8_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Object {\"a\": Bool(false)}"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_8_0"
|
|
}
|
|
},
|
|
{
|
|
"code": "STRICT_PROPERTY_VIOLATION",
|
|
"values": {
|
|
"property_name": "a"
|
|
},
|
|
"details": {
|
|
"path": "a",
|
|
"schema": "const_8_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "{\"a\": 0.0} is invalid",
|
|
"data": {
|
|
"a": 0
|
|
},
|
|
"schema_id": "const_8_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Object {\"a\": Bool(false)}"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_8_0"
|
|
}
|
|
},
|
|
{
|
|
"code": "STRICT_PROPERTY_VIOLATION",
|
|
"values": {
|
|
"property_name": "a"
|
|
},
|
|
"details": {
|
|
"path": "a",
|
|
"schema": "const_8_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "const with {\"a\": true} does not match {\"a\": 1}",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_9_0",
|
|
"schemas": {
|
|
"const_9_0": {
|
|
"const": {
|
|
"a": true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "{\"a\": true} is valid",
|
|
"data": {
|
|
"a": true
|
|
},
|
|
"schema_id": "const_9_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "{\"a\": 1} is invalid",
|
|
"data": {
|
|
"a": 1
|
|
},
|
|
"schema_id": "const_9_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Object {\"a\": Bool(true)}"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_9_0"
|
|
}
|
|
},
|
|
{
|
|
"code": "STRICT_PROPERTY_VIOLATION",
|
|
"values": {
|
|
"property_name": "a"
|
|
},
|
|
"details": {
|
|
"path": "a",
|
|
"schema": "const_9_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "{\"a\": 1.0} is invalid",
|
|
"data": {
|
|
"a": 1
|
|
},
|
|
"schema_id": "const_9_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Object {\"a\": Bool(true)}"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_9_0"
|
|
}
|
|
},
|
|
{
|
|
"code": "STRICT_PROPERTY_VIOLATION",
|
|
"values": {
|
|
"property_name": "a"
|
|
},
|
|
"details": {
|
|
"path": "a",
|
|
"schema": "const_9_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "const with 0 does not match other zero-like types",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_10_0",
|
|
"schemas": {
|
|
"const_10_0": {
|
|
"const": 0
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "false is invalid",
|
|
"data": false,
|
|
"schema_id": "const_10_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Number(0)"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_10_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "integer zero is valid",
|
|
"data": 0,
|
|
"schema_id": "const_10_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "float zero is valid",
|
|
"data": 0,
|
|
"schema_id": "const_10_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "empty object is invalid",
|
|
"data": {},
|
|
"schema_id": "const_10_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Number(0)"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_10_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "empty array is invalid",
|
|
"data": [],
|
|
"schema_id": "const_10_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Number(0)"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_10_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "empty string is invalid",
|
|
"data": "",
|
|
"schema_id": "const_10_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Number(0)"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_10_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "const with 1 does not match true",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_11_0",
|
|
"schemas": {
|
|
"const_11_0": {
|
|
"const": 1
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "true is invalid",
|
|
"data": true,
|
|
"schema_id": "const_11_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Number(1)"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_11_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "integer one is valid",
|
|
"data": 1,
|
|
"schema_id": "const_11_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "float one is valid",
|
|
"data": 1,
|
|
"schema_id": "const_11_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "const with -2.0 matches integer and float types",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_12_0",
|
|
"schemas": {
|
|
"const_12_0": {
|
|
"const": -2
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "integer -2 is valid",
|
|
"data": -2,
|
|
"schema_id": "const_12_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "integer 2 is invalid",
|
|
"data": 2,
|
|
"schema_id": "const_12_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Number(-2)"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_12_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "float -2.0 is valid",
|
|
"data": -2,
|
|
"schema_id": "const_12_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "float 2.0 is invalid",
|
|
"data": 2,
|
|
"schema_id": "const_12_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Number(-2)"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_12_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "float -2.00001 is invalid",
|
|
"data": -2.00001,
|
|
"schema_id": "const_12_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Number(-2)"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_12_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "float and integers are equal up to 64-bit representation limits",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_13_0",
|
|
"schemas": {
|
|
"const_13_0": {
|
|
"const": 9007199254740992
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "integer is valid",
|
|
"data": 9007199254740992,
|
|
"schema_id": "const_13_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "integer minus one is invalid",
|
|
"data": 9007199254740991,
|
|
"schema_id": "const_13_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Number(9007199254740992)"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_13_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "float is valid",
|
|
"data": 9007199254740992,
|
|
"schema_id": "const_13_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "float minus one is invalid",
|
|
"data": 9007199254740991,
|
|
"schema_id": "const_13_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Number(9007199254740992)"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_13_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "nul characters in strings",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_14_0",
|
|
"schemas": {
|
|
"const_14_0": {
|
|
"const": "hello\u0000there"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "match string with nul",
|
|
"data": "hello\u0000there",
|
|
"schema_id": "const_14_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "do not match string lacking nul",
|
|
"data": "hellothere",
|
|
"schema_id": "const_14_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "String(\"hello\\0there\")"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_14_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "characters with the same visual representation but different codepoint",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_15_0",
|
|
"schemas": {
|
|
"const_15_0": {
|
|
"const": "μ",
|
|
"$comment": "U+03BC"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "character uses the same codepoint",
|
|
"data": "μ",
|
|
"comment": "U+03BC",
|
|
"schema_id": "const_15_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "character looks the same but uses a different codepoint",
|
|
"data": "µ",
|
|
"comment": "U+00B5",
|
|
"schema_id": "const_15_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "String(\"μ\")"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_15_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "characters with the same visual representation, but different number of codepoints",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_16_0",
|
|
"schemas": {
|
|
"const_16_0": {
|
|
"const": "ä",
|
|
"$comment": "U+00E4"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "character uses the same codepoint",
|
|
"data": "ä",
|
|
"comment": "U+00E4",
|
|
"schema_id": "const_16_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "character looks the same but uses combining marks",
|
|
"data": "ä",
|
|
"comment": "a, U+0308",
|
|
"schema_id": "const_16_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "String(\"ä\")"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_16_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "extensible: true allows extra properties in const object match",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "const_17_0",
|
|
"schemas": {
|
|
"const_17_0": {
|
|
"const": {
|
|
"a": 1
|
|
},
|
|
"extensible": true
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "extra property ignored during strict check, but const check still applies (mismatch)",
|
|
"data": {
|
|
"a": 1,
|
|
"b": 2
|
|
},
|
|
"schema_id": "const_17_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "CONST_VIOLATED",
|
|
"values": {
|
|
"expected": "Object {\"a\": Number(1)}"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "const_17_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "extra property match in const (this is effectively impossible if data has extra props not in const, it implicitly fails const check unless we assume const check ignored extra props? No, const check is strict. So this test is just to show strictness passes.)",
|
|
"data": {
|
|
"a": 1
|
|
},
|
|
"schema_id": "const_17_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
}
|
|
]
|
|
}
|
|
] |