use-zod-default 1.0.22 → 1.0.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/v3.js +8 -2
- package/dist/v4.js +8 -2
- package/package.json +1 -1
package/dist/v3.js
CHANGED
|
@@ -190,10 +190,16 @@ const defaultInstance = (schema, source = {}) => {
|
|
|
190
190
|
// Process defined schema properties
|
|
191
191
|
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
192
192
|
if (key in source) {
|
|
193
|
-
|
|
193
|
+
const v = processValue(fieldSchema, source[key]);
|
|
194
|
+
if (v !== undefined) {
|
|
195
|
+
result[key] = v;
|
|
196
|
+
}
|
|
194
197
|
}
|
|
195
198
|
else {
|
|
196
|
-
|
|
199
|
+
const v = getDefaultValue(fieldSchema);
|
|
200
|
+
if (v !== undefined) {
|
|
201
|
+
result[key] = v;
|
|
202
|
+
}
|
|
197
203
|
}
|
|
198
204
|
}
|
|
199
205
|
// Handle passthrough - preserve additional properties not in schema
|
package/dist/v4.js
CHANGED
|
@@ -273,10 +273,16 @@ const defaultInstance = (schema, source) => {
|
|
|
273
273
|
// Create a proper ZodType from the field schema
|
|
274
274
|
const zodFieldSchema = cast(fieldSchema);
|
|
275
275
|
if (source && key in source) {
|
|
276
|
-
|
|
276
|
+
const v = processValue(zodFieldSchema, source[key]);
|
|
277
|
+
if (v !== undefined) {
|
|
278
|
+
result[key] = v;
|
|
279
|
+
}
|
|
277
280
|
}
|
|
278
281
|
else {
|
|
279
|
-
|
|
282
|
+
const v = getDefaultValue(zodFieldSchema);
|
|
283
|
+
if (v !== undefined) {
|
|
284
|
+
result[key] = v;
|
|
285
|
+
}
|
|
280
286
|
}
|
|
281
287
|
}
|
|
282
288
|
// Handle catchall - preserve additional properties not in schema
|
package/package.json
CHANGED