use-zod-default 1.0.11 → 1.0.12

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.
Files changed (2) hide show
  1. package/dist/index.js +5 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,10 +1,14 @@
1
1
  import cloneDeep from 'lodash/cloneDeep';
2
+ import isPlainObject from 'lodash/isPlainObject';
2
3
  import { z } from 'zod';
3
4
  const defaultInstance = (schema, source = {}) => {
4
5
  const getDefaultValue = (schema) => {
5
6
  if (schema instanceof z.ZodDefault) {
6
7
  const d = schema._def.defaultValue();
7
- return cloneDeep(d);
8
+ if (isPlainObject(d)) {
9
+ return cloneDeep(d);
10
+ }
11
+ return d;
8
12
  }
9
13
  if (schema instanceof z.ZodAny) {
10
14
  return undefined;
package/package.json CHANGED
@@ -30,5 +30,5 @@
30
30
  "test": "vitest",
31
31
  "test:coverage": "rm -rf coverage && vitest --run --coverage"
32
32
  },
33
- "version": "1.0.11"
33
+ "version": "1.0.12"
34
34
  }