rouzer 1.0.0-beta.22 → 1.0.0-beta.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/router.js +8 -2
- package/package.json +1 -1
package/dist/server/router.js
CHANGED
|
@@ -145,6 +145,10 @@ const seen = new WeakMap();
|
|
|
145
145
|
* value as a number or boolean.
|
|
146
146
|
*/
|
|
147
147
|
function enableStringParsing(schema) {
|
|
148
|
+
if (schema.type === 'optional') {
|
|
149
|
+
const { innerType } = schema.def;
|
|
150
|
+
return z.optional(enableStringParsing(innerType));
|
|
151
|
+
}
|
|
148
152
|
if (schema.type === 'number') {
|
|
149
153
|
return z.pipe(z.transform(Number), schema);
|
|
150
154
|
}
|
|
@@ -156,12 +160,14 @@ function enableStringParsing(schema) {
|
|
|
156
160
|
if (cached) {
|
|
157
161
|
return cached;
|
|
158
162
|
}
|
|
159
|
-
const
|
|
163
|
+
const { shape } = schema.def;
|
|
164
|
+
const modified = z.object(mapValues(shape, enableStringParsing));
|
|
160
165
|
seen.set(schema, modified);
|
|
161
166
|
return modified;
|
|
162
167
|
}
|
|
163
168
|
if (schema.type === 'array') {
|
|
164
|
-
|
|
169
|
+
const { element } = schema.def;
|
|
170
|
+
return z.array(enableStringParsing(element));
|
|
165
171
|
}
|
|
166
172
|
return schema;
|
|
167
173
|
}
|