File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,16 @@ export const parseUrlSearchParams = (
22
22
)
23
23
}
24
24
25
+ // TODO:
26
+ // const paramSchema = zodSchemaToParamSchema(schema)
27
+ // traverse paramSchema, and build a new object
28
+ // for each node, lookup expected key in searchParams
29
+ // if match, try to parse and include in object, otherwise, skip node
30
+
31
+ // TODO: For array parsing, try to lookup foo=, then foo[]= patterns,
32
+ // if only one match, try to detect commas, otherwise ignore commas.
33
+ // if both foo= and foo[]= this is a parse error
34
+
25
35
const obj : Record < string , unknown > = { }
26
36
for ( const [ k , v ] of Object . entries (
27
37
schema . shape as unknown as Record < string , unknown > ,
Original file line number Diff line number Diff line change
1
+ // TODO: unsupported types (parsing error):
2
+ // bigint: strings that are too big for Number
3
+ // any other arrays types, e.g., boolean_array, null_array
4
+ // arrays with mixed value types
5
+ // arrays containing object schemas or other arrays
6
+
7
+ import type { ZodTypeAny } from 'zod'
8
+
9
+ type ValueType =
10
+ | 'string'
11
+ | 'number'
12
+ | 'boolean'
13
+ | 'date'
14
+ | 'string_array'
15
+ | 'number_array'
16
+
17
+ interface ParamSchema {
18
+ [ key : string ] : ParamSchema | ValueType
19
+ }
20
+
21
+ export const zodSchemaToParamSchema = ( _schema : ZodTypeAny ) : ParamSchema => {
22
+ return { }
23
+ }
You can’t perform that action at this time.
0 commit comments