|
1 | 1 | [
|
2 | 2 | {
|
3 |
| - "description": "integer type", |
| 3 | + "description": "integer type matches integers", |
4 | 4 | "schema": {"type": "integer"},
|
5 | 5 | "tests": [
|
6 | 6 | {
|
|
41 | 41 | ]
|
42 | 42 | },
|
43 | 43 | {
|
44 |
| - "description": "number type", |
| 44 | + "description": "number type matches numbers", |
45 | 45 | "schema": {"type": "number"},
|
46 | 46 | "tests": [
|
47 | 47 | {
|
|
82 | 82 | ]
|
83 | 83 | },
|
84 | 84 | {
|
85 |
| - "description": "string type", |
| 85 | + "description": "string type matches strings", |
86 | 86 | "schema": {"type": "string"},
|
87 | 87 | "tests": [
|
88 | 88 | {
|
|
123 | 123 | ]
|
124 | 124 | },
|
125 | 125 | {
|
126 |
| - "description": "object type", |
| 126 | + "description": "object type matches objects", |
127 | 127 | "schema": {"type": "object"},
|
128 | 128 | "tests": [
|
129 | 129 | {
|
|
164 | 164 | ]
|
165 | 165 | },
|
166 | 166 | {
|
167 |
| - "description": "array type", |
| 167 | + "description": "array type matches arrays", |
168 | 168 | "schema": {"type": "array"},
|
169 | 169 | "tests": [
|
170 | 170 | {
|
|
205 | 205 | ]
|
206 | 206 | },
|
207 | 207 | {
|
208 |
| - "description": "boolean type", |
| 208 | + "description": "boolean type matches booleans", |
209 | 209 | "schema": {"type": "boolean"},
|
210 | 210 | "tests": [
|
211 | 211 | {
|
|
246 | 246 | ]
|
247 | 247 | },
|
248 | 248 | {
|
249 |
| - "description": "null type", |
| 249 | + "description": "null type matches only the null object", |
250 | 250 | "schema": {"type": "null"},
|
251 | 251 | "tests": [
|
252 | 252 | {
|
|
287 | 287 | ]
|
288 | 288 | },
|
289 | 289 | {
|
290 |
| - "description": "any type", |
| 290 | + "description": "any type matches any type", |
291 | 291 | "schema": {"type": "any"},
|
292 | 292 | "tests": [
|
293 | 293 | {
|
|
326 | 326 | "valid": true
|
327 | 327 | }
|
328 | 328 | ]
|
| 329 | + }, |
| 330 | + { |
| 331 | + "description": "multiple types can be specified in an array", |
| 332 | + "schema": {"type": ["integer", "string"]}, |
| 333 | + "tests": [ |
| 334 | + { |
| 335 | + "description": "an integer is valid", |
| 336 | + "data": 1, |
| 337 | + "valid": true |
| 338 | + }, |
| 339 | + { |
| 340 | + "description": "a string is valid", |
| 341 | + "data": "foo", |
| 342 | + "valid": true |
| 343 | + }, |
| 344 | + { |
| 345 | + "description": "a float is invalid", |
| 346 | + "data": 1.1, |
| 347 | + "valid": false |
| 348 | + }, |
| 349 | + { |
| 350 | + "description": "an object is invalid", |
| 351 | + "data": {}, |
| 352 | + "valid": false |
| 353 | + }, |
| 354 | + { |
| 355 | + "description": "an array is invalid", |
| 356 | + "data": [], |
| 357 | + "valid": false |
| 358 | + }, |
| 359 | + { |
| 360 | + "description": "a boolean is invalid", |
| 361 | + "data": true, |
| 362 | + "valid": false |
| 363 | + }, |
| 364 | + { |
| 365 | + "description": "null is invalid", |
| 366 | + "data": null, |
| 367 | + "valid": false |
| 368 | + } |
| 369 | + ] |
| 370 | + }, |
| 371 | + { |
| 372 | + "description": "types can include schemas", |
| 373 | + "schema": { |
| 374 | + "type": [ |
| 375 | + "array", |
| 376 | + {"type": "object"} |
| 377 | + ] |
| 378 | + }, |
| 379 | + "tests": [ |
| 380 | + { |
| 381 | + "description": "an integer is invalid", |
| 382 | + "data": 1, |
| 383 | + "valid": false |
| 384 | + }, |
| 385 | + { |
| 386 | + "description": "a string is invalid", |
| 387 | + "data": "foo", |
| 388 | + "valid": false |
| 389 | + }, |
| 390 | + { |
| 391 | + "description": "a float is invalid", |
| 392 | + "data": 1.1, |
| 393 | + "valid": false |
| 394 | + }, |
| 395 | + { |
| 396 | + "description": "an object is valid", |
| 397 | + "data": {}, |
| 398 | + "valid": true |
| 399 | + }, |
| 400 | + { |
| 401 | + "description": "an array is valid", |
| 402 | + "data": [], |
| 403 | + "valid": true |
| 404 | + }, |
| 405 | + { |
| 406 | + "description": "a boolean is invalid", |
| 407 | + "data": true, |
| 408 | + "valid": false |
| 409 | + }, |
| 410 | + { |
| 411 | + "description": "null is invalid", |
| 412 | + "data": null, |
| 413 | + "valid": false |
| 414 | + } |
| 415 | + ] |
| 416 | + }, |
| 417 | + { |
| 418 | + "description": |
| 419 | + "when types includes a schema it should fully validate the schema", |
| 420 | + "schema": { |
| 421 | + "type": [ |
| 422 | + "integer", |
| 423 | + { |
| 424 | + "properties": { |
| 425 | + "foo": {"type": "null"} |
| 426 | + } |
| 427 | + } |
| 428 | + ] |
| 429 | + }, |
| 430 | + "tests": [ |
| 431 | + { |
| 432 | + "description": "an integer is valid", |
| 433 | + "data": 1, |
| 434 | + "valid": true |
| 435 | + }, |
| 436 | + { |
| 437 | + "description": "an object is valid only if it is fully valid", |
| 438 | + "data": {"foo": null}, |
| 439 | + "valid": true |
| 440 | + }, |
| 441 | + { |
| 442 | + "description": "an object is invalid otherwise", |
| 443 | + "data": {"foo": "bar"}, |
| 444 | + "valid": false |
| 445 | + }, |
| 446 | + ] |
| 447 | + }, |
| 448 | + { |
| 449 | + "description": "types from separate schemas are merged", |
| 450 | + "schema": { |
| 451 | + "type": [ |
| 452 | + {"type": ["string"]}, |
| 453 | + {"type": ["array", "null"]}, |
| 454 | + ] |
| 455 | + }, |
| 456 | + "tests": [ |
| 457 | + { |
| 458 | + "description": "an integer is invalid", |
| 459 | + "data": 1, |
| 460 | + "valid": false |
| 461 | + }, |
| 462 | + { |
| 463 | + "description": "a string is valid", |
| 464 | + "data": "foo", |
| 465 | + "valid": true |
| 466 | + }, |
| 467 | + { |
| 468 | + "description": "an array is valid", |
| 469 | + "data": [1, 2, 3], |
| 470 | + "valid": true |
| 471 | + } |
| 472 | + ] |
329 | 473 | }
|
330 | 474 | ]
|
0 commit comments