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