@@ -592,10 +592,8 @@ export const BIGINT_FORMAT_RANGES: Record<checks.$ZodBigIntFormats, [bigint, big
592592
593593export function pick ( schema : schemas . $ZodObject , mask : Record < string , unknown > ) : any {
594594 const currDef = schema . _zod . def ;
595- if ( ( currDef . checks ?? [ ] ) . length > 0 ) {
596- throw new Error ( "Invalid .pick() on object schemas containing refinements" ) ;
597- }
598- const def = mergeDefs ( currDef , {
595+
596+ const def = mergeDefs ( schema . _zod . def , {
599597 get shape ( ) {
600598 const newShape : Writeable < schemas . $ZodShape > = { } ;
601599 for ( const key in mask ) {
@@ -617,13 +615,10 @@ export function pick(schema: schemas.$ZodObject, mask: Record<string, unknown>):
617615
618616export function omit ( schema : schemas . $ZodObject , mask : object ) : any {
619617 const currDef = schema . _zod . def ;
620- if ( ( currDef . checks ?? [ ] ) . length > 0 ) {
621- throw new Error ( "Invalid .omit() on object schemas containing refinements" ) ;
622- }
623618
624- const def = mergeDefs ( currDef , {
619+ const def = mergeDefs ( schema . _zod . def , {
625620 get shape ( ) {
626- const newShape : Writeable < schemas . $ZodShape > = { ...currDef . shape } ;
621+ const newShape : Writeable < schemas . $ZodShape > = { ...schema . _zod . def . shape } ;
627622 for ( const key in mask ) {
628623 if ( ! ( key in currDef . shape ) ) {
629624 throw new Error ( `Unrecognized key: "${ key } "` ) ;
@@ -649,7 +644,7 @@ export function extend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): an
649644 const checks = schema . _zod . def . checks ;
650645 const hasChecks = checks && checks . length > 0 ;
651646 if ( hasChecks ) {
652- throw new Error ( "Invalid .extend() on object schemas containing refinements. Use .safeExtend() instead." ) ;
647+ throw new Error ( "Object schemas containing refinements cannot be extended . Use ` .safeExtend()` instead." ) ;
653648 }
654649
655650 const def = mergeDefs ( schema . _zod . def , {
0 commit comments