| 1 |
[ |
| 2 |
{ |
| 3 |
"description": "simple enum validation", |
| 4 |
"schema": {"enum": [1, 2, 3]}, |
| 5 |
"tests": [ |
| 6 |
{ |
| 7 |
"description": "one of the enum is valid", |
| 8 |
"data": 1, |
| 9 |
"valid": true |
| 10 |
}, |
| 11 |
{ |
| 12 |
"description": "something else is invalid", |
| 13 |
"data": 4, |
| 14 |
"valid": false |
| 15 |
} |
| 16 |
] |
| 17 |
}, |
| 18 |
{ |
| 19 |
"description": "heterogeneous enum validation", |
| 20 |
"schema": {"enum": [6, "foo", [], true, {"foo": 12}]}, |
| 21 |
"tests": [ |
| 22 |
{ |
| 23 |
"description": "one of the enum is valid", |
| 24 |
"data": [], |
| 25 |
"valid": true |
| 26 |
}, |
| 27 |
{ |
| 28 |
"description": "something else is invalid", |
| 29 |
"data": null, |
| 30 |
"valid": false |
| 31 |
}, |
| 32 |
{ |
| 33 |
"description": "objects are deep compared", |
| 34 |
"data": {"foo": false}, |
| 35 |
"valid": false |
| 36 |
} |
| 37 |
] |
| 38 |
}, |
| 39 |
{ |
| 40 |
"description": "heterogeneous enum-with-null validation", |
| 41 |
"schema": { "enum": [6, null] }, |
| 42 |
"tests": [ |
| 43 |
{ |
| 44 |
"description": "null is valid", |
| 45 |
"data": null, |
| 46 |
"valid": true |
| 47 |
}, |
| 48 |
{ |
| 49 |
"description": "number is valid", |
| 50 |
"data": 6, |
| 51 |
"valid": true |
| 52 |
}, |
| 53 |
{ |
| 54 |
"description": "something else is invalid", |
| 55 |
"data": "test", |
| 56 |
"valid": false |
| 57 |
} |
| 58 |
] |
| 59 |
}, |
| 60 |
{ |
| 61 |
"description": "enums in properties", |
| 62 |
"schema": { |
| 63 |
"type":"object", |
| 64 |
"properties": { |
| 65 |
"foo": {"enum":["foo"]}, |
| 66 |
"bar": {"enum":["bar"], "required":true} |
| 67 |
} |
| 68 |
}, |
| 69 |
"tests": [ |
| 70 |
{ |
| 71 |
"description": "both properties are valid", |
| 72 |
"data": {"foo":"foo", "bar":"bar"}, |
| 73 |
"valid": true |
| 74 |
}, |
| 75 |
{ |
| 76 |
"description": "wrong foo value", |
| 77 |
"data": {"foo":"foot", "bar":"bar"}, |
| 78 |
"valid": false |
| 79 |
}, |
| 80 |
{ |
| 81 |
"description": "wrong bar value", |
| 82 |
"data": {"foo":"foo", "bar":"bart"}, |
| 83 |
"valid": false |
| 84 |
}, |
| 85 |
{ |
| 86 |
"description": "missing optional property is valid", |
| 87 |
"data": {"bar":"bar"}, |
| 88 |
"valid": true |
| 89 |
}, |
| 90 |
{ |
| 91 |
"description": "missing required property is invalid", |
| 92 |
"data": {"foo":"foo"}, |
| 93 |
"valid": false |
| 94 |
}, |
| 95 |
{ |
| 96 |
"description": "missing all properties is invalid", |
| 97 |
"data": {}, |
| 98 |
"valid": false |
| 99 |
} |
| 100 |
] |
| 101 |
}, |
| 102 |
{ |
| 103 |
"description": "nul characters in strings", |
| 104 |
"schema": { "enum": [ "hello\u0000there" ] }, |
| 105 |
"tests": [ |
| 106 |
{ |
| 107 |
"description": "match string with nul", |
| 108 |
"data": "hello\u0000there", |
| 109 |
"valid": true |
| 110 |
}, |
| 111 |
{ |
| 112 |
"description": "do not match string lacking nul", |
| 113 |
"data": "hellothere", |
| 114 |
"valid": false |
| 115 |
} |
| 116 |
] |
| 117 |
}, |
| 118 |
{ |
| 119 |
"description": "characters with the same visual representation, but different number of codepoints", |
| 120 |
"schema": { |
| 121 |
"enum": ["ä"], |
| 122 |
"$comment": "U+00E4" |
| 123 |
}, |
| 124 |
"tests": [ |
| 125 |
{ |
| 126 |
"description": "character uses the same codepoint", |
| 127 |
"data": "ä", |
| 128 |
"comment": "U+00E4", |
| 129 |
"valid": true |
| 130 |
}, |
| 131 |
{ |
| 132 |
"description": "character looks the same but uses combining marks", |
| 133 |
"data": "ä", |
| 134 |
"comment": "a, U+0308", |
| 135 |
"valid": false |
| 136 |
} |
| 137 |
] |
| 138 |
} |
| 139 |
] |