@@ -4,29 +4,29 @@ import { expectError, expectType } from 'tsd'
44
55// Number schemas
66build ( {
7- type : 'number'
7+ type : 'number'
88} ) ( 25 )
99build ( {
10- type : 'integer'
10+ type : 'integer'
1111} ) ( - 5 )
1212build ( {
13- type : 'integer'
13+ type : 'integer'
1414} ) ( 5n )
1515
1616build ( {
17- type : 'number'
17+ type : 'number'
1818} , { rounding : 'ceil' } )
1919build ( {
20- type : 'number'
20+ type : 'number'
2121} , { rounding : 'floor' } )
2222build ( {
23- type : 'number'
23+ type : 'number'
2424} , { rounding : 'round' } )
2525build ( {
26- type : 'number'
26+ type : 'number'
2727} , { rounding : 'trunc' } )
2828expectError ( build ( {
29- type : 'number'
29+ type : 'number'
3030} , { rounding : 'invalid' } ) )
3131
3232// String schema
@@ -36,55 +36,55 @@ build({
3636
3737// Boolean schema
3838build ( {
39- type : 'boolean'
39+ type : 'boolean'
4040} ) ( true )
4141
4242// Null schema
4343build ( {
44- type : 'null'
44+ type : 'null'
4545} ) ( null )
4646
4747// Array schemas
4848build ( {
49- type : 'array' ,
50- items : { type : 'number' }
49+ type : 'array' ,
50+ items : { type : 'number' }
5151} ) ( [ 25 ] )
5252build ( {
53- type : 'array' ,
54- items : [ { type : 'string' } , { type : 'integer' } ]
53+ type : 'array' ,
54+ items : [ { type : 'string' } , { type : 'integer' } ]
5555} ) ( [ 'hello' , 42 ] )
5656
5757// Object schemas
5858build ( {
59- type : 'object'
59+ type : 'object'
6060} ) ( { } )
6161build ( {
62- type : 'object' ,
63- properties : {
64- foo : { type : 'string' } ,
65- bar : { type : 'integer' }
66- } ,
67- required : [ 'foo' ] ,
68- patternProperties : {
69- 'baz*' : { type : 'null' }
70- } ,
71- additionalProperties : {
72- type : 'boolean'
73- }
62+ type : 'object' ,
63+ properties : {
64+ foo : { type : 'string' } ,
65+ bar : { type : 'integer' }
66+ } ,
67+ required : [ 'foo' ] ,
68+ patternProperties : {
69+ 'baz*' : { type : 'null' }
70+ } ,
71+ additionalProperties : {
72+ type : 'boolean'
73+ }
7474} ) ( { foo : 'bar' } )
7575build ( {
76- type : 'object' ,
77- properties : {
78- foo : { type : 'string' } ,
79- bar : { type : 'integer' }
80- } ,
81- required : [ 'foo' ] ,
82- patternProperties : {
83- 'baz*' : { type : 'null' }
84- } ,
85- additionalProperties : {
86- type : 'boolean'
87- }
76+ type : 'object' ,
77+ properties : {
78+ foo : { type : 'string' } ,
79+ bar : { type : 'integer' }
80+ } ,
81+ required : [ 'foo' ] ,
82+ patternProperties : {
83+ 'baz*' : { type : 'null' }
84+ } ,
85+ additionalProperties : {
86+ type : 'boolean'
87+ }
8888} , { rounding : 'floor' } ) ( { foo : 'bar' } )
8989
9090// Reference schemas
@@ -113,7 +113,7 @@ build({
113113 }
114114 } ,
115115 patternProperties : {
116- ' num' : {
116+ num : {
117117 $ref : '#/definitions/num'
118118 }
119119 } ,
@@ -207,52 +207,52 @@ interface InferenceSchema {
207207}
208208
209209const stringify3 = build ( {
210- type : " object" ,
211- properties : { a : { type : " string" } } ,
212- } ) ;
213- stringify3 < InferenceSchema > ( { id : " 123" } ) ;
214- stringify3 < InferenceSchema > ( { a : 123 , id : " 123" } ) ;
215- expectError ( stringify3 < InferenceSchema > ( { anotherOne : " bar" } ) ) ;
216- expectError ( stringify3 < Schema > ( { a : " bar" } ) ) ;
210+ type : ' object' ,
211+ properties : { a : { type : ' string' } } ,
212+ } )
213+ stringify3 < InferenceSchema > ( { id : ' 123' } )
214+ stringify3 < InferenceSchema > ( { a : 123 , id : ' 123' } )
215+ expectError ( stringify3 < InferenceSchema > ( { anotherOne : ' bar' } ) )
216+ expectError ( stringify3 < Schema > ( { a : ' bar' } ) )
217217
218218// Without inference
219219const stringify4 = build ( {
220- type : " object" ,
221- properties : { a : { type : " string" } } ,
222- } ) ;
223- stringify4 ( { id : " 123" } ) ;
224- stringify4 ( { a : 123 , id : " 123" } ) ;
225- stringify4 ( { anotherOne : " bar" } ) ;
226- stringify4 ( { a : " bar" } ) ;
220+ type : ' object' ,
221+ properties : { a : { type : ' string' } } ,
222+ } )
223+ stringify4 ( { id : ' 123' } )
224+ stringify4 ( { a : 123 , id : ' 123' } )
225+ stringify4 ( { anotherOne : ' bar' } )
226+ stringify4 ( { a : ' bar' } )
227227
228228// Without inference - string type
229229const stringify5 = build ( {
230- type : " string" ,
231- } ) ;
232- stringify5 ( " foo" ) ;
233- expectError ( stringify5 ( { id : " 123" } ) ) ;
230+ type : ' string' ,
231+ } )
232+ stringify5 ( ' foo' )
233+ expectError ( stringify5 ( { id : ' 123' } ) )
234234
235235// Without inference - null type
236236const stringify6 = build ( {
237- type : " null" ,
238- } ) ;
239- stringify6 ( null ) ;
240- expectError ( stringify6 ( " a string" ) ) ;
237+ type : ' null' ,
238+ } )
239+ stringify6 ( null )
240+ expectError ( stringify6 ( ' a string' ) )
241241
242242// Without inference - boolean type
243243const stringify7 = build ( {
244- type : " boolean" ,
245- } ) ;
246- stringify7 ( true ) ;
247- expectError ( stringify7 ( " a string" ) ) ;
244+ type : ' boolean' ,
245+ } )
246+ stringify7 ( true )
247+ expectError ( stringify7 ( ' a string' ) )
248248
249249// largeArrayMechanism
250250
251- build ( { } , { largeArrayMechanism : 'json-stringify' } )
252- build ( { } , { largeArrayMechanism : 'default' } )
253- expectError ( build ( { } as Schema , { largeArrayMechanism : 'invalid' } ) )
251+ build ( { } , { largeArrayMechanism : 'json-stringify' } )
252+ build ( { } , { largeArrayMechanism : 'default' } )
253+ expectError ( build ( { } as Schema , { largeArrayMechanism : 'invalid' } ) )
254254
255- build ( { } , { largeArraySize : 2000 } )
256- build ( { } , { largeArraySize : '2e4' } )
257- build ( { } , { largeArraySize : 2n } )
258- expectError ( build ( { } as Schema , { largeArraySize : [ 'asdf' ] } ) )
255+ build ( { } , { largeArraySize : 2000 } )
256+ build ( { } , { largeArraySize : '2e4' } )
257+ build ( { } , { largeArraySize : 2n } )
258+ expectError ( build ( { } as Schema , { largeArraySize : [ 'asdf' ] } ) )
0 commit comments