@ramiyohay/schema-faker 0.5.0 → 0.6.0
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/README.md +9 -0
- package/dist/core/context.d.ts +1 -0
- package/dist/generate.js +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/zod/parseZod.js +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,4 +79,13 @@ const user = generate(UserSchema, {
|
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
console.log(user);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Strict mode
|
|
85
|
+
|
|
86
|
+
By default, unsupported Zod types are ignored.
|
|
87
|
+
Enable strict mode to throw an error instead:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
generate(schema, { strict: true });
|
|
82
91
|
```
|
package/dist/core/context.d.ts
CHANGED
package/dist/generate.js
CHANGED
package/dist/types.d.ts
CHANGED
package/dist/zod/parseZod.js
CHANGED
|
@@ -57,6 +57,9 @@ function parseZodSchema(schema, ctx) {
|
|
|
57
57
|
case "ZodDate": // Date type
|
|
58
58
|
return (0, date_1.generateDate)(schema, ctx);
|
|
59
59
|
default:
|
|
60
|
-
|
|
60
|
+
if (ctx.strict) {
|
|
61
|
+
throw new Error(`Unsupported Zod type: ${schema._def.typeName}`);
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
61
64
|
}
|
|
62
65
|
}
|