1
1
{
2
- "title" : " Complex Form Example" ,
3
- "description" : " This form demonstrates various JSON Schema features including arrays of oneOf" ,
2
+ "title" : " Multi-Select Example" ,
4
3
"type" : " object" ,
5
- "required" : [" name" , " age" , " contacts" , " preferences" ],
6
4
"properties" : {
7
- "name" : {
8
- "type" : " string" ,
9
- "title" : " Full Name" ,
10
- "minLength" : 2 ,
11
- "maxLength" : 100
12
- },
13
- "age" : {
14
- "type" : " integer" ,
15
- "title" : " Age" ,
16
- "minimum" : 0 ,
17
- "maximum" : 150
18
- },
19
- "contacts" : {
5
+ "colors" : {
20
6
"type" : " array" ,
21
- "title" : " Contact Methods" ,
22
- "description" : " Add one or more contact methods" ,
23
- "minItems" : 1 ,
7
+ "title" : " Select Colors" ,
8
+ "description" : " Choose one or more colors" ,
24
9
"items" : {
25
- "oneOf" : [
26
- {
27
- "type" : " object" ,
28
- "title" : " Email Contact" ,
29
- "required" : [" type" , " email" ],
30
- "properties" : {
31
- "type" : {
32
- "const" : " email"
33
- },
34
- "email" : {
35
- "type" : " string" ,
36
- "format" : " email"
37
- },
38
- "preferred" : {
39
- "type" : " boolean" ,
40
- "default" : false
41
- }
42
- }
43
- },
44
- {
45
- "type" : " object" ,
46
- "title" : " Phone Contact" ,
47
- "required" : [" type" , " phone" ],
48
- "properties" : {
49
- "type" : {
50
- "const" : " phone"
51
- },
52
- "phone" : {
53
- "type" : " string" ,
54
- "pattern" : " ^\\ +?[1-9]\\ d{1,14}$"
55
- },
56
- "preferred" : {
57
- "type" : " boolean" ,
58
- "default" : false
59
- }
60
- }
61
- }
62
- ]
63
- }
64
- },
65
- "preferences" : {
66
- "type" : " object" ,
67
- "title" : " Preferences" ,
68
- "required" : [" theme" ],
69
- "properties" : {
70
- "theme" : {
71
- "type" : " string" ,
72
- "enum" : [" light" , " dark" , " system" ],
73
- "default" : " system"
74
- },
75
- "notifications" : {
76
- "type" : " boolean" ,
77
- "title" : " Enable Notifications" ,
78
- "default" : true
79
- },
80
- "newsletter" : {
81
- "type" : " string" ,
82
- "title" : " Newsletter Frequency" ,
83
- "oneOf" : [
84
- {
85
- "const" : " never" ,
86
- "title" : " Never"
87
- },
88
- {
89
- "const" : " daily" ,
90
- "title" : " Daily"
91
- },
92
- {
93
- "const" : " weekly" ,
94
- "title" : " Weekly"
95
- },
96
- {
97
- "const" : " monthly" ,
98
- "title" : " Monthly"
99
- }
100
- ],
101
- "default" : " never"
102
- }
103
- }
104
- },
105
- "address" : {
106
- "type" : " object" ,
107
- "title" : " Address" ,
108
- "properties" : {
109
- "street" : {
110
- "type" : " string" ,
111
- "title" : " Street"
112
- },
113
- "city" : {
114
- "type" : " string" ,
115
- "title" : " City"
116
- },
117
- "country" : {
118
- "type" : " string" ,
119
- "title" : " Country" ,
120
- "enum" : [" USA" , " Canada" , " UK" , " Other" ]
121
- },
122
- "postal" : {
123
- "type" : " string" ,
124
- "title" : " Postal Code" ,
125
- "pattern" : " ^[A-Z0-9]{3,10}$"
126
- }
10
+ "type" : " string" ,
11
+ "enum" : [" red" , " green" , " blue" , " yellow" , " purple" , " orange" ]
127
12
},
128
- "required" : [" street" , " city" , " country" ]
129
- },
130
- "dates" : {
131
- "type" : " array" ,
132
- "title" : " Important Dates" ,
133
- "items" : {
134
- "oneOf" : [
135
- {
136
- "type" : " object" ,
137
- "title" : " Birthday" ,
138
- "required" : [" type" , " date" ],
139
- "properties" : {
140
- "type" : {
141
- "const" : " birthday"
142
- },
143
- "date" : {
144
- "type" : " string" ,
145
- "format" : " date"
146
- }
147
- }
148
- },
149
- {
150
- "type" : " object" ,
151
- "title" : " Anniversary" ,
152
- "required" : [" type" , " date" , " description" ],
153
- "properties" : {
154
- "type" : {
155
- "const" : " anniversary"
156
- },
157
- "date" : {
158
- "type" : " string" ,
159
- "format" : " date"
160
- },
161
- "description" : {
162
- "type" : " string" ,
163
- "maxLength" : 100
164
- }
165
- }
166
- }
167
- ]
168
- }
13
+ "uniqueItems" : true ,
14
+ "minItems" : 1 ,
15
+ "maxItems" : 3
169
16
}
170
17
}
171
18
}
0 commit comments