@@ -1167,14 +1167,14 @@ export class InputValidator<Schema extends SchemaDef> {
11671167 uncheckedVariantFields [ field ] = fieldSchema ;
11681168 }
11691169 } else {
1170- let fieldSchema : ZodType = this . makePrimitiveSchema ( fieldDef . type , fieldDef . attributes ) . optional ( ) ;
1170+ let fieldSchema : ZodType = this . makePrimitiveSchema ( fieldDef . type , fieldDef . attributes ) ;
11711171
11721172 if ( this . isNumericField ( fieldDef ) ) {
11731173 fieldSchema = z . union ( [
11741174 fieldSchema ,
11751175 z
11761176 . object ( {
1177- set : this . nullableIf ( z . number ( ) . optional ( ) , ! ! fieldDef . optional ) ,
1177+ set : this . nullableIf ( z . number ( ) . optional ( ) , ! ! fieldDef . optional ) . optional ( ) ,
11781178 increment : z . number ( ) . optional ( ) ,
11791179 decrement : z . number ( ) . optional ( ) ,
11801180 multiply : z . number ( ) . optional ( ) ,
@@ -1189,26 +1189,24 @@ export class InputValidator<Schema extends SchemaDef> {
11891189
11901190 if ( fieldDef . array ) {
11911191 const arraySchema = addListValidation ( fieldSchema . array ( ) , fieldDef . attributes ) ;
1192- fieldSchema = z
1193- . union ( [
1194- arraySchema ,
1195- z
1196- . object ( {
1197- set : arraySchema . optional ( ) ,
1198- push : z . union ( [ fieldSchema , fieldSchema . array ( ) ] ) . optional ( ) ,
1199- } )
1200- . refine (
1201- ( v ) => Object . keys ( v ) . length === 1 ,
1202- 'Only one of "set", "push" can be provided' ,
1203- ) ,
1204- ] )
1205- . optional ( ) ;
1192+ fieldSchema = z . union ( [
1193+ arraySchema ,
1194+ z
1195+ . object ( {
1196+ set : arraySchema . optional ( ) ,
1197+ push : z . union ( [ fieldSchema , fieldSchema . array ( ) ] ) . optional ( ) ,
1198+ } )
1199+ . refine ( ( v ) => Object . keys ( v ) . length === 1 , 'Only one of "set", "push" can be provided' ) ,
1200+ ] ) ;
12061201 }
12071202
12081203 if ( fieldDef . optional ) {
12091204 fieldSchema = fieldSchema . nullable ( ) ;
12101205 }
12111206
1207+ // all fields are optional in update
1208+ fieldSchema = fieldSchema . optional ( ) ;
1209+
12121210 uncheckedVariantFields [ field ] = fieldSchema ;
12131211 if ( ! fieldDef . foreignKeyFor ) {
12141212 // non-fk field
0 commit comments