use-zod-default 1.0.13 → 1.0.14
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/index.js +9 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -187,6 +187,7 @@ const defaultInstance = (schema, source = {}) => {
|
|
|
187
187
|
const processObject = (schema, source) => {
|
|
188
188
|
const result = {};
|
|
189
189
|
const shape = schema.shape;
|
|
190
|
+
// Process defined schema properties
|
|
190
191
|
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
191
192
|
if (key in source) {
|
|
192
193
|
result[key] = processValue(fieldSchema, source[key]);
|
|
@@ -195,6 +196,14 @@ const defaultInstance = (schema, source = {}) => {
|
|
|
195
196
|
result[key] = getDefaultValue(fieldSchema);
|
|
196
197
|
}
|
|
197
198
|
}
|
|
199
|
+
// Handle passthrough - preserve additional properties not in schema
|
|
200
|
+
if (schema._def.unknownKeys === 'passthrough' && isPlainObject(source)) {
|
|
201
|
+
for (const key in source) {
|
|
202
|
+
if (!(key in shape)) {
|
|
203
|
+
result[key] = source[key];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
198
207
|
return result;
|
|
199
208
|
};
|
|
200
209
|
const processRecord = (schema, source) => {
|
package/package.json
CHANGED