| •1 |
[ |
| 2 |
{ |
| 3 |
"description": "contains keyword validation", |
| 4 |
"schema": { |
| 5 |
"contains": {"minimum": 5} |
| 6 |
}, |
| 7 |
"tests": [ |
| 8 |
{ |
| 9 |
"description": "array with item matching schema (5) is valid", |
| 10 |
"data": [3, 4, 5], |
| 11 |
"valid": true |
| 12 |
}, |
| 13 |
{ |
| 14 |
"description": "array with item matching schema (6) is valid", |
| 15 |
"data": [3, 4, 6], |
| 16 |
"valid": true |
| 17 |
}, |
| 18 |
{ |
| 19 |
"description": "array with two items matching schema (5, 6) is valid", |
| 20 |
"data": [3, 4, 5, 6], |
| 21 |
"valid": true |
| 22 |
}, |
| 23 |
{ |
| 24 |
"description": "array without items matching schema is invalid", |
| 25 |
"data": [2, 3, 4], |
| 26 |
"valid": false |
| 27 |
}, |
| 28 |
{ |
| 29 |
"description": "empty array is invalid", |
| 30 |
"data": [], |
| 31 |
"valid": false |
| 32 |
}, |
| 33 |
{ |
| 34 |
"description": "not array is valid", |
| 35 |
"data": {}, |
| 36 |
"valid": true |
| 37 |
} |
| 38 |
] |
| 39 |
}, |
| 40 |
{ |
| 41 |
"description": "contains keyword with const keyword", |
| 42 |
"schema": { |
| 43 |
"contains": { "const": 5 } |
| 44 |
}, |
| 45 |
"tests": [ |
| 46 |
{ |
| 47 |
"description": "array with item 5 is valid", |
| 48 |
"data": [3, 4, 5], |
| 49 |
"valid": true |
| 50 |
}, |
| 51 |
{ |
| 52 |
"description": "array with two items 5 is valid", |
| 53 |
"data": [3, 4, 5, 5], |
| 54 |
"valid": true |
| 55 |
}, |
| 56 |
{ |
| 57 |
"description": "array without item 5 is invalid", |
| 58 |
"data": [1, 2, 3, 4], |
| 59 |
"valid": false |
| 60 |
} |
| 61 |
] |
| 62 |
}, |
| 63 |
{ |
| 64 |
"description": "contains keyword with boolean schema true", |
| 65 |
"schema": {"contains": true}, |
| 66 |
"tests": [ |
| 67 |
{ |
| 68 |
"description": "any non-empty array is valid", |
| 69 |
"data": ["foo"], |
| 70 |
"valid": true |
| 71 |
}, |
| 72 |
{ |
| 73 |
"description": "empty array is invalid", |
| 74 |
"data": [], |
| 75 |
"valid": false |
| 76 |
} |
| 77 |
] |
| 78 |
}, |
| 79 |
{ |
| 80 |
"description": "contains keyword with boolean schema false", |
| 81 |
"schema": {"contains": false}, |
| 82 |
"tests": [ |
| 83 |
{ |
| 84 |
"description": "any non-empty array is invalid", |
| 85 |
"data": ["foo"], |
| 86 |
"valid": false |
| 87 |
}, |
| 88 |
{ |
| 89 |
"description": "empty array is invalid", |
| 90 |
"data": [], |
| 91 |
"valid": false |
| 92 |
}, |
| 93 |
{ |
| 94 |
"description": "non-arrays are valid", |
| 95 |
"data": "contains does not apply to strings", |
| 96 |
"valid": true |
| 97 |
} |
| 98 |
] |
| 99 |
}, |
| 100 |
{ |
| 101 |
"description": "items + contains", |
| 102 |
"schema": { |
| 103 |
"items": { "multipleOf": 2 }, |
| 104 |
"contains": { "multipleOf": 3 } |
| 105 |
}, |
| 106 |
"tests": [ |
| 107 |
{ |
| 108 |
"description": "matches items, does not match contains", |
| 109 |
"data": [ 2, 4, 8 ], |
| 110 |
"valid": false |
| 111 |
}, |
| 112 |
{ |
| 113 |
"description": "does not match items, matches contains", |
| 114 |
"data": [ 3, 6, 9 ], |
| 115 |
"valid": false |
| 116 |
}, |
| 117 |
{ |
| 118 |
"description": "matches both items and contains", |
| 119 |
"data": [ 6, 12 ], |
| 120 |
"valid": true |
| 121 |
}, |
| 122 |
{ |
| 123 |
"description": "matches neither items nor contains", |
| 124 |
"data": [ 1, 5 ], |
| 125 |
"valid": false |
| 126 |
} |
| 127 |
] |
| 128 |
}, |
| 129 |
{ |
| 130 |
"description": "contains with false if subschema", |
| 131 |
"schema": { |
| 132 |
"contains": { |
| 133 |
"if": false, |
| 134 |
"else": true |
| 135 |
} |
| 136 |
}, |
| 137 |
"tests": [ |
| 138 |
{ |
| 139 |
"description": "any non-empty array is valid", |
| 140 |
"data": ["foo"], |
| 141 |
"valid": true |
| 142 |
}, |
| 143 |
{ |
| 144 |
"description": "empty array is invalid", |
| 145 |
"data": [], |
| 146 |
"valid": false |
| 147 |
} |
| 148 |
] |
| 149 |
} |
| 150 |
] |