Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81160 views
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
"[email protected]",
18
"&'*+-./=?^_{}[email protected]",
19
"mixed-1234-in-{+^}[email protected]",
20
"[email protected]",
21
"\"quoted\"@sld.com",
22
"\"\\e\\s\\c\\a\\p\\e\\d\"@sld.com",
23
"\"[email protected]\"@sld.com",
24
"\"escaped\\\"quote\"@sld.com",
25
"\"back\\slash\"@sld.com",
26
"[email protected]",
27
"[email protected]",
28
"[email protected]",
29
"[email protected]",
30
"[email protected]",
31
"[email protected]",
32
"[email protected]",
33
"[email protected]",
34
"[email protected]",
35
"[email protected]",
36
"[email protected]",
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
"[email protected]"
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
44
exports.invalid = {
45
fullName : null,
46
age : -1,
47
state : 47,
48
city : false,
49
zip : [null],
50
married : "yes",
51
dozen : 50,
52
dozenOrBakersDozen : "over 9000",
53
favoriteEvenNumber : 15,
54
topThreeFavoriteColors : [ "red", 5 ],
55
favoriteSingleDigitWholeNumbers : [ 78, 2, 999 ],
56
favoriteFiveLetterWord : "codernaut",
57
emailAddresses : [],
58
ipAddresses : [ "999.0.099.1", "294.48.64.2346", false, "2221409.64214128.42414.235233", "124124.12412412" ]
59
}
60
61
exports.schema = { // from cosmic thingy
62
name : "test",
63
type : "object",
64
additionalProperties : false,
65
required : ["fullName", "age", "zip", "married", "dozen", "dozenOrBakersDozen", "favoriteEvenNumber", "topThreeFavoriteColors", "favoriteSingleDigitWholeNumbers", "favoriteFiveLetterWord", "emailAddresses", "ipAddresses"],
66
properties :
67
{
68
fullName : { type : "string" },
69
age : { type : "integer", minimum : 0 },
70
optionalItem : { type : "string" },
71
state : { type : "string" },
72
city : { type : "string" },
73
zip : { type : "integer", minimum : 0, maximum : 99999 },
74
married : { type : "boolean" },
75
dozen : { type : "integer", minimum : 12, maximum : 12 },
76
dozenOrBakersDozen : { type : "integer", minimum : 12, maximum : 13 },
77
favoriteEvenNumber : { type : "integer", multipleOf : 2 },
78
topThreeFavoriteColors : { type : "array", minItems : 3, maxItems : 3, uniqueItems : true, items : { type : "string" }},
79
favoriteSingleDigitWholeNumbers : { type : "array", minItems : 1, maxItems : 10, uniqueItems : true, items : { type : "integer", minimum : 0, maximum : 9 }},
80
favoriteFiveLetterWord : { type : "string", minLength : 5, maxLength : 5 },
81
emailAddresses : { type : "array", minItems : 1, uniqueItems : true, items : { type : "string", format : "email" }},
82
ipAddresses : { type : "array", uniqueItems : true, items : { type : "string", format : "ipv4" }},
83
}
84
}
85