File tree 1 file changed +13
-3
lines changed
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,12 @@ const generateZodValidationSchemaDefinition = (
90
90
91
91
functions . push ( [ type as string , undefined ] ) ;
92
92
93
- if ( schema . format === 'date-time' || schema . format === 'date' ) {
93
+ if ( schema . format === 'date' ) {
94
+ functions . push ( [ 'regex' , 'new RegExp(/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/)' ] ) ;
95
+ break ;
96
+ }
97
+
98
+ if ( schema . format === 'date-time' ) {
94
99
functions . push ( [ 'datetime' , undefined ] ) ;
95
100
break ;
96
101
}
@@ -177,8 +182,12 @@ const generateZodValidationSchemaDefinition = (
177
182
}
178
183
179
184
if ( min !== undefined ) {
180
- consts . push ( `export const ${ name } Min = ${ min } ;` ) ;
181
- functions . push ( [ 'min' , `${ name } Min` ] ) ;
185
+ if ( min === 1 ) {
186
+ functions . push ( [ 'min' , `${ min } ` ] ) ;
187
+ } else {
188
+ consts . push ( `export const ${ name } Min = ${ min } ;` ) ;
189
+ functions . push ( [ 'min' , `${ name } Min` ] ) ;
190
+ }
182
191
}
183
192
if ( max !== undefined ) {
184
193
consts . push ( `export const ${ name } Max = ${ max } ;` ) ;
@@ -281,6 +290,7 @@ const parseZodValidationSchemaDefinition = (
281
290
}
282
291
if ( fn === 'array' ) {
283
292
const value = args . functions . map ( parseProperty ) . join ( '' ) ;
293
+ consts += args . consts ;
284
294
return `.array(${ value . startsWith ( '.' ) ? 'zod' : '' } ${ value } )` ;
285
295
}
286
296
return `.${ fn } (${ args } )` ;
You can’t perform that action at this time.
1 commit comments
vercel[bot] commentedon Sep 28, 2023
Successfully deployed to the following URLs:
orval – ./
orval.dev
orval-anymaniax.vercel.app
orval.vercel.app
www.orval.dev
orval-git-master-anymaniax.vercel.app