File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 6
6
7
7
import type { ZodTypeAny } from 'zod'
8
8
9
+ import { isZodObject } from './zod.js'
10
+
9
11
type ValueType =
10
12
| 'string'
11
13
| 'number'
@@ -18,6 +20,18 @@ interface ParamSchema {
18
20
[ key : string ] : ParamSchema | ValueType
19
21
}
20
22
21
- export const zodSchemaToParamSchema = ( _schema : ZodTypeAny ) : ParamSchema => {
23
+ export const zodSchemaToParamSchema = ( schema : ZodTypeAny ) : ParamSchema => {
24
+ if ( ! isZodObject ( schema ) ) {
25
+ throw new UnparseableSchemaError (
26
+ 'top level schema must be an object schema' ,
27
+ )
28
+ }
22
29
return { }
23
30
}
31
+
32
+ export class UnparseableSchemaError extends Error {
33
+ constructor ( message : string ) {
34
+ super ( `Could not parse Zod schema: ${ message } ` )
35
+ this . name = this . constructor . name
36
+ }
37
+ }
You can’t perform that action at this time.
0 commit comments