enum.json 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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": "enums in properties",
  41. "schema": {
  42. "type":"object",
  43. "properties": {
  44. "foo": {"enum":["foo"]},
  45. "bar": {"enum":["bar"], "required":true}
  46. }
  47. },
  48. "tests": [
  49. {
  50. "description": "both properties are valid",
  51. "data": {"foo":"foo", "bar":"bar"},
  52. "valid": true
  53. },
  54. {
  55. "description": "missing optional property is valid",
  56. "data": {"bar":"bar"},
  57. "valid": true
  58. },
  59. {
  60. "description": "missing required property is invalid",
  61. "data": {"foo":"foo"},
  62. "valid": false
  63. },
  64. {
  65. "description": "missing all properties is invalid",
  66. "data": {},
  67. "valid": false
  68. }
  69. ]
  70. }
  71. ]