2
2
3
3
import * as v from 'valibot' ;
4
4
5
+ /**
6
+ * Testing multiline comments in string: First line
7
+ * Second line
8
+ *
9
+ * Fourth line
10
+ */
5
11
export const vCommentWithBreaks = v . pipe ( v . number ( ) , v . integer ( ) ) ;
6
12
13
+ /**
14
+ * Testing backticks in string: `backticks` and ```multiple backticks``` should work
15
+ */
7
16
export const vCommentWithBackticks = v . pipe ( v . number ( ) , v . integer ( ) ) ;
8
17
18
+ /**
19
+ * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work
20
+ */
9
21
export const vCommentWithBackticksAndQuotes = v . pipe ( v . number ( ) , v . integer ( ) ) ;
10
22
23
+ /**
24
+ * Testing slashes in string: \backwards\\\ and /forwards/// should work
25
+ */
11
26
export const vCommentWithSlashes = v . pipe ( v . number ( ) , v . integer ( ) ) ;
12
27
28
+ /**
29
+ * Testing expression placeholders in string: ${expression} should work
30
+ */
13
31
export const vCommentWithExpressionPlaceholders = v . pipe ( v . number ( ) , v . integer ( ) ) ;
14
32
33
+ /**
34
+ * Testing quotes in string: 'single quote''' and "double quotes""" should work
35
+ */
15
36
export const vCommentWithQuotes = v . pipe ( v . number ( ) , v . integer ( ) ) ;
16
37
38
+ /**
39
+ * Testing reserved characters in string: * inline * and ** inline ** should work
40
+ */
17
41
export const vCommentWithReservedCharacters = v . pipe ( v . number ( ) , v . integer ( ) ) ;
18
42
43
+ /**
44
+ * This is a simple number
45
+ */
19
46
export const vSimpleInteger = v . pipe ( v . number ( ) , v . integer ( ) ) ;
20
47
48
+ /**
49
+ * This is a simple boolean
50
+ */
21
51
export const vSimpleBoolean = v . boolean ( ) ;
22
52
53
+ /**
54
+ * This is a simple string
55
+ */
23
56
export const vSimpleString = v . string ( ) ;
24
57
58
+ /**
59
+ * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)
60
+ */
25
61
export const vNonAsciiStringæøåÆøÅöôêÊ字符串 = v . string ( ) ;
26
62
63
+ /**
64
+ * This is a simple file
65
+ */
27
66
export const vSimpleFile = v . string ( ) ;
28
67
68
+ /**
69
+ * This is a model with one string property
70
+ */
29
71
export const vModelWithString = v . object ( {
30
72
prop : v . optional ( v . string ( ) )
31
73
} ) ;
32
74
33
75
export const vSimpleReference = vModelWithString ;
34
76
77
+ /**
78
+ * This is a simple string
79
+ */
35
80
export const vSimpleStringWithPattern = v . pipe ( v . string ( ) , v . maxLength ( 64 ) , v . regex ( / ^ [ a - z A - Z 0 - 9 _ ] * $ / ) ) ;
36
81
82
+ /**
83
+ * This is a simple enum with strings
84
+ */
37
85
export const vEnumWithStrings = v . picklist ( [
38
86
'Success' ,
39
87
'Warning' ,
@@ -43,51 +91,108 @@ export const vEnumWithStrings = v.picklist([
43
91
'Non-ascii: øæåôöØÆÅÔÖ字符串'
44
92
] ) ;
45
93
94
+ /**
95
+ * This is a simple enum with numbers
96
+ */
46
97
export const vEnumWithNumbers = v . unknown ( ) ;
47
98
99
+ /**
100
+ * Success=1,Warning=2,Error=3
101
+ */
48
102
export const vEnumFromDescription = v . number ( ) ;
49
103
104
+ /**
105
+ * This is a simple enum with numbers
106
+ */
50
107
export const vEnumWithExtensions = v . unknown ( ) ;
51
108
109
+ /**
110
+ * This is a simple array with numbers
111
+ */
52
112
export const vArrayWithNumbers = v . array ( v . pipe ( v . number ( ) , v . integer ( ) ) ) ;
53
113
114
+ /**
115
+ * This is a simple array with booleans
116
+ */
54
117
export const vArrayWithBooleans = v . array ( v . boolean ( ) ) ;
55
118
119
+ /**
120
+ * This is a simple array with strings
121
+ */
56
122
export const vArrayWithStrings = v . array ( v . string ( ) ) ;
57
123
124
+ /**
125
+ * This is a simple array with references
126
+ */
58
127
export const vArrayWithReferences = v . array ( vModelWithString ) ;
59
128
129
+ /**
130
+ * This is a simple array containing an array
131
+ */
60
132
export const vArrayWithArray = v . array ( v . array ( vModelWithString ) ) ;
61
133
134
+ /**
135
+ * This is a simple array with properties
136
+ */
62
137
export const vArrayWithProperties = v . array ( v . object ( {
63
138
foo : v . optional ( v . string ( ) ) ,
64
139
bar : v . optional ( v . string ( ) )
65
140
} ) ) ;
66
141
142
+ /**
143
+ * This is a string dictionary
144
+ */
67
145
export const vDictionaryWithString = v . object ( { } ) ;
68
146
147
+ /**
148
+ * This is a string reference
149
+ */
69
150
export const vDictionaryWithReference = v . object ( { } ) ;
70
151
152
+ /**
153
+ * This is a complex dictionary
154
+ */
71
155
export const vDictionaryWithArray = v . object ( { } ) ;
72
156
157
+ /**
158
+ * This is a string dictionary
159
+ */
73
160
export const vDictionaryWithDictionary = v . object ( { } ) ;
74
161
162
+ /**
163
+ * This is a complex dictionary
164
+ */
75
165
export const vDictionaryWithProperties = v . object ( { } ) ;
76
166
167
+ /**
168
+ * This is a type-only model that defines Date as a string
169
+ */
77
170
export const vDate = v . string ( ) ;
78
171
172
+ /**
173
+ * This is a model with one number property
174
+ */
79
175
export const vModelWithInteger = v . object ( {
80
176
prop : v . optional ( v . pipe ( v . number ( ) , v . integer ( ) ) )
81
177
} ) ;
82
178
179
+ /**
180
+ * This is a model with one boolean property
181
+ */
83
182
export const vModelWithBoolean = v . object ( {
84
183
prop : v . optional ( v . boolean ( ) )
85
184
} ) ;
86
185
186
+ /**
187
+ * This is a model with one string property
188
+ */
87
189
export const vModelWithStringError = v . object ( {
88
190
prop : v . optional ( v . string ( ) )
89
191
} ) ;
90
192
193
+ /**
194
+ * This is a model with one string property
195
+ */
91
196
export const vModelWithNullableString = v . object ( {
92
197
nullableProp : v . optional ( v . union ( [
93
198
v . string ( ) ,
@@ -99,6 +204,9 @@ export const vModelWithNullableString = v.object({
99
204
] )
100
205
} ) ;
101
206
207
+ /**
208
+ * This is a model with one enum
209
+ */
102
210
export const vModelWithEnum = v . object ( {
103
211
test : v . optional ( v . picklist ( [
104
212
'Success' ,
@@ -117,10 +225,16 @@ export const vModelWithEnum = v.object({
117
225
bool : v . optional ( v . unknown ( ) )
118
226
} ) ;
119
227
228
+ /**
229
+ * This is a model with one enum
230
+ */
120
231
export const vModelWithEnumFromDescription = v . object ( {
121
232
test : v . optional ( v . pipe ( v . number ( ) , v . integer ( ) ) )
122
233
} ) ;
123
234
235
+ /**
236
+ * This is a model with nested enums
237
+ */
124
238
export const vModelWithNestedEnums = v . object ( {
125
239
dictionaryWithEnum : v . optional ( v . object ( { } ) ) ,
126
240
dictionaryWithEnumFromDescription : v . optional ( v . object ( { } ) ) ,
@@ -132,6 +246,9 @@ export const vModelWithNestedEnums = v.object({
132
246
arrayWithDescription : v . optional ( v . array ( v . pipe ( v . number ( ) , v . integer ( ) ) ) )
133
247
} ) ;
134
248
249
+ /**
250
+ * This is a model with one nested property
251
+ */
135
252
export const vModelWithProperties = v . object ( {
136
253
required : v . string ( ) ,
137
254
requiredAndReadOnly : v . pipe ( v . string ( ) , v . readonly ( ) ) ,
@@ -146,26 +263,41 @@ export const vModelWithProperties = v.object({
146
263
'@namespace.integer' : v . optional ( v . pipe ( v . pipe ( v . number ( ) , v . integer ( ) ) , v . readonly ( ) ) )
147
264
} ) ;
148
265
266
+ /**
267
+ * This is a model with one property containing a reference
268
+ */
149
269
export const vModelWithReference = v . object ( {
150
270
prop : v . optional ( vModelWithProperties )
151
271
} ) ;
152
272
273
+ /**
274
+ * This is a model with one property containing an array
275
+ */
153
276
export const vModelWithArray = v . object ( {
154
277
prop : v . optional ( v . array ( vModelWithString ) ) ,
155
278
propWithFile : v . optional ( v . array ( v . string ( ) ) ) ,
156
279
propWithNumber : v . optional ( v . array ( v . number ( ) ) )
157
280
} ) ;
158
281
282
+ /**
283
+ * This is a model with one property containing a dictionary
284
+ */
159
285
export const vModelWithDictionary = v . object ( {
160
286
prop : v . optional ( v . object ( { } ) )
161
287
} ) ;
162
288
289
+ /**
290
+ * This is a model with one property containing a circular reference
291
+ */
163
292
export const vModelWithCircularReference : v . GenericSchema = v . object ( {
164
293
prop : v . optional ( v . lazy ( ( ) => {
165
294
return vModelWithCircularReference ;
166
295
} ) )
167
296
} ) ;
168
297
298
+ /**
299
+ * This is a model with one nested property
300
+ */
169
301
export const vModelWithNestedProperties = v . object ( {
170
302
first : v . pipe ( v . object ( {
171
303
second : v . pipe ( v . object ( {
@@ -174,22 +306,34 @@ export const vModelWithNestedProperties = v.object({
174
306
} ) , v . readonly ( ) )
175
307
} ) ;
176
308
309
+ /**
310
+ * This is a model with duplicated properties
311
+ */
177
312
export const vModelWithDuplicateProperties = v . object ( {
178
313
prop : v . optional ( vModelWithString )
179
314
} ) ;
180
315
316
+ /**
317
+ * This is a model with ordered properties
318
+ */
181
319
export const vModelWithOrderedProperties = v . object ( {
182
320
zebra : v . optional ( v . string ( ) ) ,
183
321
apple : v . optional ( v . string ( ) ) ,
184
322
hawaii : v . optional ( v . string ( ) )
185
323
} ) ;
186
324
325
+ /**
326
+ * This is a model with duplicated imports
327
+ */
187
328
export const vModelWithDuplicateImports = v . object ( {
188
329
propA : v . optional ( vModelWithString ) ,
189
330
propB : v . optional ( vModelWithString ) ,
190
331
propC : v . optional ( vModelWithString )
191
332
} ) ;
192
333
334
+ /**
335
+ * This is a model that extends another model
336
+ */
193
337
export const vModelThatExtends = v . intersect ( [
194
338
vModelWithString ,
195
339
v . object ( {
@@ -198,6 +342,9 @@ export const vModelThatExtends = v.intersect([
198
342
} )
199
343
] ) ;
200
344
345
+ /**
346
+ * This is a model that extends another model
347
+ */
201
348
export const vModelThatExtendsExtends = v . intersect ( [
202
349
vModelWithString ,
203
350
vModelThatExtends ,
@@ -211,6 +358,9 @@ export const vDefault = v.object({
211
358
name : v . optional ( v . string ( ) )
212
359
} ) ;
213
360
361
+ /**
362
+ * This is a model that contains a some patterns
363
+ */
214
364
export const vModelWithPattern = v . object ( {
215
365
key : v . pipe ( v . string ( ) , v . maxLength ( 64 ) , v . regex ( / ^ [ a - z A - Z 0 - 9 _ ] * $ / ) ) ,
216
366
name : v . pipe ( v . string ( ) , v . maxLength ( 255 ) ) ,
@@ -250,8 +400,14 @@ export const vCallWithResponseAndNoContentResponseResponse = v.union([
250
400
v . unknown ( )
251
401
] ) ;
252
402
403
+ /**
404
+ * Message for default response
405
+ */
253
406
export const vCallWithResponseResponse = vModelWithString ;
254
407
408
+ /**
409
+ * Message for 201 response
410
+ */
255
411
export const vCallWithDuplicateResponsesResponse = vModelWithString ;
256
412
257
413
export const vCallWithResponsesResponse = v . union ( [
@@ -271,8 +427,17 @@ export const vTypesResponse = v.union([
271
427
v . object ( { } )
272
428
] ) ;
273
429
430
+ /**
431
+ * Successful response
432
+ */
274
433
export const vComplexTypesResponse = v . array ( vModelWithString ) ;
275
434
435
+ /**
436
+ * Successful response
437
+ */
276
438
export const vNonAsciiæøåÆøÅöôêÊ字符串Response = vNonAsciiStringæøåÆøÅöôêÊ字符串 ;
277
439
440
+ /**
441
+ * OK
442
+ */
278
443
export const vPostApiVbyApiVersionBodyResponse = vResponsePostActivityResponse ;
0 commit comments