@@ -1434,22 +1434,39 @@ export function _custom<O = unknown, I = O>(
14341434 fn : ( data : O ) => unknown ,
14351435 _params : string | $ZodCustomParams | undefined
14361436) : schemas . $ZodCustom < O , I > {
1437+ const norm = util . normalizeParams ( _params ) ;
1438+ norm . abort ??= true ; // default to abort:false
14371439 const schema = new Class ( {
14381440 type : "custom" ,
14391441 check : "custom" ,
14401442 fn : fn as any ,
1441- ...util . normalizeParams ( _params ) ,
1443+ ...norm ,
14421444 } ) ;
14431445
14441446 return schema as any ;
14451447}
14461448
1447- export function _refine < T > (
1449+ // export function _refine<T>(
1450+ // Class: util.SchemaClass<schemas.$ZodCustom>,
1451+ // fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>,
1452+ // _params: string | $ZodCustomParams = {}
1453+ // ): checks.$ZodCheck<T> {
1454+ // return _custom(Class, fn, _params);
1455+ // }
1456+ // same as _custom but deafults to abort:false
1457+ export function _refine < O = unknown , I = O > (
14481458 Class : util . SchemaClass < schemas . $ZodCustom > ,
1449- fn : ( arg : NoInfer < T > ) => util . MaybeAsync < unknown > ,
1450- _params : string | $ZodCustomParams = { }
1451- ) : checks . $ZodCheck < T > {
1452- return _custom ( Class , fn , _params ) ;
1459+ fn : ( data : O ) => unknown ,
1460+ _params : string | $ZodCustomParams | undefined
1461+ ) : schemas . $ZodCustom < O , I > {
1462+ const schema = new Class ( {
1463+ type : "custom" ,
1464+ check : "custom" ,
1465+ fn : fn as any ,
1466+ ...util . normalizeParams ( _params ) ,
1467+ } ) ;
1468+
1469+ return schema as any ;
14531470}
14541471
14551472// export type $ZodCustomParams = CheckTypeParams<schemas.$ZodCustom, "fn">
0 commit comments