File tree 1 file changed +7
-5
lines changed
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -58,10 +58,8 @@ const generateZodValidationSchemaDefinition = (
58
58
const consts = [ ] ;
59
59
const functions : [ string , any ] [ ] = [ ] ;
60
60
const type = resolveZodType ( schema . type ) ;
61
- const required =
62
- schema . default !== undefined
63
- ? false
64
- : _required ?? ! schema . nullable ?? false ;
61
+ const required = schema . default !== undefined ? false : _required ?? false ;
62
+ const nullable = schema . nullable ?? false ;
65
63
const min =
66
64
schema . minimum ?? schema . exclusiveMinimum ?? schema . minLength ?? undefined ;
67
65
const max =
@@ -200,7 +198,11 @@ const generateZodValidationSchemaDefinition = (
200
198
] ) ;
201
199
}
202
200
203
- if ( ! required ) {
201
+ if ( ! required && nullable ) {
202
+ functions . push ( [ 'nullish' , undefined ] ) ;
203
+ } else if ( nullable ) {
204
+ functions . push ( [ 'nullable' , undefined ] ) ;
205
+ } else if ( ! required ) {
204
206
functions . push ( [ 'optional' , undefined ] ) ;
205
207
}
206
208
You can’t perform that action at this time.
1 commit comments
vercel[bot] commentedon May 17, 2023
Successfully deployed to the following URLs:
orval – ./
www.orval.dev
orval-git-master-anymaniax.vercel.app
orval.vercel.app
orval-anymaniax.vercel.app
orval.dev