@@ -55,6 +55,28 @@ export interface ZodType<
55
55
params ?: core . ParseContext < core . $ZodIssue >
56
56
) => Promise < parse . ZodSafeParseResult < core . output < this> > > ;
57
57
58
+ // encoding/decoding
59
+ encode ( data : core . output < this> , params ?: core . ParseContext < core . $ZodIssue > ) : core . input < this> ;
60
+ decode ( data : core . input < this> , params ?: core . ParseContext < core . $ZodIssue > ) : core . output < this> ;
61
+ encodeAsync ( data : core . output < this> , params ?: core . ParseContext < core . $ZodIssue > ) : Promise < core . input < this> > ;
62
+ decodeAsync ( data : core . input < this> , params ?: core . ParseContext < core . $ZodIssue > ) : Promise < core . output < this> > ;
63
+ safeEncode (
64
+ data : core . output < this> ,
65
+ params ?: core . ParseContext < core . $ZodIssue >
66
+ ) : parse . ZodSafeParseResult < core . input < this> > ;
67
+ safeDecode (
68
+ data : core . input < this> ,
69
+ params ?: core . ParseContext < core . $ZodIssue >
70
+ ) : parse . ZodSafeParseResult < core . output < this> > ;
71
+ safeEncodeAsync (
72
+ data : core . output < this> ,
73
+ params ?: core . ParseContext < core . $ZodIssue >
74
+ ) : Promise < parse . ZodSafeParseResult < core . input < this> > > ;
75
+ safeDecodeAsync (
76
+ data : core . input < this> ,
77
+ params ?: core . ParseContext < core . $ZodIssue >
78
+ ) : Promise < parse . ZodSafeParseResult < core . output < this> > > ;
79
+
58
80
// refinements
59
81
refine ( check : ( arg : core . output < this> ) => unknown | Promise < unknown > , params ?: string | core . $ZodCustomParams ) : this;
60
82
superRefine (
@@ -150,6 +172,16 @@ export const ZodType: core.$constructor<ZodType> = /*@__PURE__*/ core.$construct
150
172
inst . safeParseAsync = async ( data , params ) => parse . safeParseAsync ( inst , data , params ) ;
151
173
inst . spa = inst . safeParseAsync ;
152
174
175
+ // encoding/decoding
176
+ inst . encode = ( data , params ) => parse . encode ( inst , data , params ) ;
177
+ inst . decode = ( data , params ) => parse . decode ( inst , data , params ) ;
178
+ inst . encodeAsync = async ( data , params ) => parse . encodeAsync ( inst , data , params ) ;
179
+ inst . decodeAsync = async ( data , params ) => parse . decodeAsync ( inst , data , params ) ;
180
+ inst . safeEncode = ( data , params ) => parse . safeEncode ( inst , data , params ) ;
181
+ inst . safeDecode = ( data , params ) => parse . safeDecode ( inst , data , params ) ;
182
+ inst . safeEncodeAsync = async ( data , params ) => parse . safeEncodeAsync ( inst , data , params ) ;
183
+ inst . safeDecodeAsync = async ( data , params ) => parse . safeDecodeAsync ( inst , data , params ) ;
184
+
153
185
// refinements
154
186
inst . refine = ( check , params ) => inst . check ( refine ( check , params ) ) ;
155
187
inst . superRefine = ( refinement ) => inst . check ( superRefine ( refinement ) ) ;
0 commit comments