@@ -6,25 +6,33 @@ import type { z } from "zod";
6
6
7
7
export type IfInstalled < T > = any extends T ? never : T ;
8
8
9
- export type Schema = IfInstalled < z . ZodType > | IfInstalled < GenericSchema | GenericSchemaAsync > | IfInstalled < YupSchema > ;
9
+ export type Schema =
10
+ | IfInstalled < z . ZodType >
11
+ | IfInstalled < GenericSchema >
12
+ | IfInstalled < GenericSchemaAsync >
13
+ | IfInstalled < YupSchema > ;
10
14
11
15
export type Infer < S extends Schema > =
12
16
S extends IfInstalled < z . ZodType >
13
17
? z . infer < S >
14
- : S extends IfInstalled < GenericSchema | GenericSchemaAsync >
18
+ : S extends IfInstalled < GenericSchema >
15
19
? InferOutput < S >
16
- : S extends IfInstalled < YupSchema >
17
- ? InferType < S >
18
- : never ;
20
+ : S extends IfInstalled < GenericSchemaAsync >
21
+ ? InferOutput < S >
22
+ : S extends IfInstalled < YupSchema >
23
+ ? InferType < S >
24
+ : never ;
19
25
20
26
export type InferIn < S extends Schema > =
21
27
S extends IfInstalled < z . ZodType >
22
28
? z . input < S >
23
- : S extends IfInstalled < GenericSchema | GenericSchemaAsync >
29
+ : S extends IfInstalled < GenericSchema >
24
30
? InferInput < S >
25
- : S extends IfInstalled < YupSchema >
26
- ? InferType < S >
27
- : never ;
31
+ : S extends IfInstalled < GenericSchemaAsync >
32
+ ? InferInput < S >
33
+ : S extends IfInstalled < YupSchema >
34
+ ? InferType < S >
35
+ : never ;
28
36
29
37
export type InferArray < BAS extends readonly Schema [ ] > = {
30
38
[ K in keyof BAS ] : Infer < BAS [ K ] > ;
@@ -50,7 +58,11 @@ export interface ValidationAdapter {
50
58
data : unknown
51
59
) : Promise < { success : true ; data : Infer < S > } | { success : false ; issues : ValidationIssue [ ] } > ;
52
60
// valibot
53
- validate < S extends IfInstalled < GenericSchema | GenericSchemaAsync > > (
61
+ validate < S extends IfInstalled < GenericSchema > > (
62
+ schema : S ,
63
+ data : unknown
64
+ ) : Promise < { success : true ; data : Infer < S > } | { success : false ; issues : ValidationIssue [ ] } > ;
65
+ validate < S extends IfInstalled < GenericSchemaAsync > > (
54
66
schema : S ,
55
67
data : unknown
56
68
) : Promise < { success : true ; data : Infer < S > } | { success : false ; issues : ValidationIssue [ ] } > ;
0 commit comments