@@ -10,8 +10,10 @@ import {
1010 SzUnion ,
1111 SzDiscriminatedUnion ,
1212 SzIntersection ,
13+ SzXor ,
1314 SzTuple ,
1415 SzRecord ,
16+ SzLooseRecord ,
1517 SzMap ,
1618 SzSet ,
1719 SzEnum ,
@@ -147,48 +149,56 @@ export type Dezerialize<T extends SzType | SzRef> = T extends SzRef
147149 Dezerialize < Key > ,
148150 Dezerialize < Value >
149151 >
150- : T extends SzMap <
152+ : T extends SzLooseRecord <
151153 infer Key ,
152154 infer Value
153155 >
154- ? z . ZodMap <
156+ ? z . ZodRecord <
155157 Dezerialize < Key > ,
156158 Dezerialize < Value >
157- > // Enum
158- : T extends SzEnum <
159- infer Values
159+ >
160+ : T extends SzMap <
161+ infer Key ,
162+ infer Value
160163 >
161- ? z . ZodEnum < Values > // Union/Intersection
162- : T extends SzUnion <
163- infer _Options
164+ ? z . ZodMap <
165+ Dezerialize < Key > ,
166+ Dezerialize < Value >
167+ > // Enum
168+ : T extends SzEnum <
169+ infer Values
164170 >
165- ? z . ZodUnion < any >
166- : T extends SzDiscriminatedUnion <
167- infer Discriminator ,
171+ ? z . ZodEnum < Values > // Union/Intersection
172+ : T extends SzUnion <
168173 infer _Options
169174 >
170- ? z . ZodDiscriminatedUnion < any >
171- : T extends SzIntersection <
172- infer L ,
173- infer R
175+ ? z . ZodUnion < any >
176+ : T extends SzDiscriminatedUnion <
177+ infer Discriminator ,
178+ infer _Options
174179 >
175- ? z . ZodIntersection <
176- Dezerialize < L > ,
177- Dezerialize < R >
178- > // Specials
179- : T extends SzPromise <
180- infer Value
181- >
182- ? z . ZodPromise <
183- Dezerialize < Value >
180+ ? z . ZodDiscriminatedUnion < any >
181+ : T extends SzIntersection <
182+ infer L ,
183+ infer R
184184 >
185- : T extends SzCatch <
185+ ? z . ZodIntersection <
186+ Dezerialize < L > ,
187+ Dezerialize < R >
188+ > // Specials
189+ : T extends SzPromise <
186190 infer Value
187191 >
188- ? z . ZodCatch <
192+ ? z . ZodPromise <
189193 Dezerialize < Value >
190194 >
191- : any ; // unknown;
195+ : T extends SzCatch <
196+ infer Value
197+ >
198+ ? z . ZodCatch <
199+ Dezerialize < Value >
200+ >
201+ : any ; // unknown;
192202
193203type DezerializersMap = {
194204 [ T in SzType [ "type" ] ] : (
@@ -535,6 +545,23 @@ const dezerializers = {
535545 opts . pathToSchema . set ( opts . path , i ) ;
536546 return getCustomChecks ( i , shape , opts ) ;
537547 } ) as any ,
548+ looseRecord : ( ( shape : SzLooseRecord , opts : DezerializerOptions ) => {
549+ const i = z . looseRecord (
550+ checkRef ( shape . key , opts ) ||
551+ ( d ( shape . key , {
552+ ...opts ,
553+ path : opts . path + "/key" ,
554+ } ) as z . ZodString | z . ZodNumber | z . ZodSymbol ) ,
555+ checkRef ( shape . value , opts ) ||
556+ d ( shape . value , {
557+ ...opts ,
558+ path : opts . path + "/value" ,
559+ } ) ,
560+ getError ( shape , opts ) ,
561+ ) ;
562+ opts . pathToSchema . set ( opts . path , i ) ;
563+ return getCustomChecks ( i , shape , opts ) ;
564+ } ) as any ,
538565 map : ( ( shape : SzMap < any , any > , opts : DezerializerOptions ) => {
539566 const i = z . map (
540567 checkRef ( shape . key , opts ) ||
@@ -591,6 +618,21 @@ const dezerializers = {
591618 opts . pathToSchema . set ( opts . path , i ) ;
592619 return getCustomChecks ( i , shape , opts ) ;
593620 } ) as any ,
621+ xor : ( ( shape : SzXor , opts : DezerializerOptions ) => {
622+ const i = z . xor (
623+ shape . options . map (
624+ ( opt , idx ) =>
625+ checkRef ( opt , opts ) ||
626+ d ( opt , {
627+ ...opts ,
628+ path : opts . path + "/options/" + idx ,
629+ } ) ,
630+ ) as any ,
631+ getError ( shape , opts ) ,
632+ ) ;
633+ opts . pathToSchema . set ( opts . path , i ) ;
634+ return getCustomChecks ( i , shape , opts ) ;
635+ } ) as any ,
594636 intersection : ( ( shape : SzIntersection , opts : DezerializerOptions ) => {
595637 const i = z . intersection (
596638 checkRef ( shape . left , opts ) ||
0 commit comments