cosmic.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. exports.valid = {
  2. fullName : "John Doe",
  3. age : 47,
  4. state : "Massachusetts",
  5. city : "Boston",
  6. zip : 16417,
  7. married : false,
  8. dozen : 12,
  9. dozenOrBakersDozen : 13,
  10. favoriteEvenNumber : 14,
  11. topThreeFavoriteColors : [ "red", "blue", "green" ],
  12. favoriteSingleDigitWholeNumbers : [ 7 ],
  13. favoriteFiveLetterWord : "coder",
  14. emailAddresses :
  15. [
  16. "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@letters-in-local.org",
  17. "01234567890@numbers-in-local.net",
  18. "&'*+-./=?^_{}~@other-valid-characters-in-local.net",
  19. "mixed-1234-in-{+^}-local@sld.net",
  20. "a@single-character-in-local.org",
  21. "\"quoted\"@sld.com",
  22. "\"\\e\\s\\c\\a\\p\\e\\d\"@sld.com",
  23. "\"quoted-at-sign@sld.org\"@sld.com",
  24. "\"escaped\\\"quote\"@sld.com",
  25. "\"back\\slash\"@sld.com",
  26. "one-character-third-level@a.example.com",
  27. "single-character-in-sld@x.org",
  28. "local@dash-in-sld.com",
  29. "letters-in-sld@123.com",
  30. "one-letter-sld@x.org",
  31. "uncommon-tld@sld.museum",
  32. "uncommon-tld@sld.travel",
  33. "uncommon-tld@sld.mobi",
  34. "country-code-tld@sld.uk",
  35. "country-code-tld@sld.rw",
  36. "local@sld.newTLD",
  37. "the-total-length@of-an-entire-address.cannot-be-longer-than-two-hundred-and-fifty-four-characters.and-this-address-is-254-characters-exactly.so-it-should-be-valid.and-im-going-to-add-some-more-words-here.to-increase-the-lenght-blah-blah-blah-blah-bla.org",
  38. "the-character-limit@for-each-part.of-the-domain.is-sixty-three-characters.this-is-exactly-sixty-three-characters-so-it-is-valid-blah-blah.com",
  39. "local@sub.domains.com"
  40. ],
  41. ipAddresses : [ "127.0.0.1", "24.48.64.2", "192.168.1.1", "209.68.44.3", "2.2.2.2" ]
  42. }
  43. exports.invalid = {
  44. fullName : null,
  45. age : -1,
  46. state : 47,
  47. city : false,
  48. zip : [null],
  49. married : "yes",
  50. dozen : 50,
  51. dozenOrBakersDozen : "over 9000",
  52. favoriteEvenNumber : 15,
  53. topThreeFavoriteColors : [ "red", 5 ],
  54. favoriteSingleDigitWholeNumbers : [ 78, 2, 999 ],
  55. favoriteFiveLetterWord : "codernaut",
  56. emailAddresses : [],
  57. ipAddresses : [ "999.0.099.1", "294.48.64.2346", false, "2221409.64214128.42414.235233", "124124.12412412" ]
  58. }
  59. exports.schema = { // from cosmic thingy
  60. name : "test",
  61. type : "object",
  62. additionalProperties : false,
  63. required : ["fullName", "age", "zip", "married", "dozen", "dozenOrBakersDozen", "favoriteEvenNumber", "topThreeFavoriteColors", "favoriteSingleDigitWholeNumbers", "favoriteFiveLetterWord", "emailAddresses", "ipAddresses"],
  64. properties :
  65. {
  66. fullName : { type : "string" },
  67. age : { type : "integer", minimum : 0 },
  68. optionalItem : { type : "string" },
  69. state : { type : "string" },
  70. city : { type : "string" },
  71. zip : { type : "integer", minimum : 0, maximum : 99999 },
  72. married : { type : "boolean" },
  73. dozen : { type : "integer", minimum : 12, maximum : 12 },
  74. dozenOrBakersDozen : { type : "integer", minimum : 12, maximum : 13 },
  75. favoriteEvenNumber : { type : "integer", multipleOf : 2 },
  76. topThreeFavoriteColors : { type : "array", minItems : 3, maxItems : 3, uniqueItems : true, items : { type : "string" }},
  77. favoriteSingleDigitWholeNumbers : { type : "array", minItems : 1, maxItems : 10, uniqueItems : true, items : { type : "integer", minimum : 0, maximum : 9 }},
  78. favoriteFiveLetterWord : { type : "string", minLength : 5, maxLength : 5 },
  79. emailAddresses : { type : "array", minItems : 1, uniqueItems : true, items : { type : "string", format : "email" }},
  80. ipAddresses : { type : "array", uniqueItems : true, items : { type : "string", format : "ipv4" }},
  81. }
  82. }