zod-nest 3.0.0 → 3.0.1
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 +2 -11
- package/dist/index.js +26 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -20
package/README.md
CHANGED
|
@@ -245,20 +245,11 @@ The id is what appears as the `components.schemas` key in the OpenAPI document a
|
|
|
245
245
|
|
|
246
246
|
```ts
|
|
247
247
|
// Preferred — on the schema, via Zod's metadata
|
|
248
|
-
const userSchema = z
|
|
249
|
-
.object({
|
|
250
|
-
/* ... */
|
|
251
|
-
})
|
|
252
|
-
.meta({ id: 'User' });
|
|
248
|
+
const userSchema = z.object({/* ... */}).meta({ id: 'User' });
|
|
253
249
|
class UserDto extends createZodDto(userSchema) {}
|
|
254
250
|
|
|
255
251
|
// Also valid — passed through createZodDto's options
|
|
256
|
-
class UserDto extends createZodDto(
|
|
257
|
-
z.object({
|
|
258
|
-
/* ... */
|
|
259
|
-
}),
|
|
260
|
-
{ id: 'User' },
|
|
261
|
-
) {}
|
|
252
|
+
class UserDto extends createZodDto(z.object({/* ... */}), { id: 'User' }) {}
|
|
262
253
|
```
|
|
263
254
|
|
|
264
255
|
Both produce the same OpenAPI output. `.meta({ id })` is preferred when the schema is hoisted into its own `const`, because the id stays with the schema — composition (`extend(parent, ...)`), shared input/output via `.meta({ id })` on the same schema reference, and any non-DTO use of the schema all pick up the same id without an extra hop through `createZodDto`'s options. Use the `createZodDto(schema, { id })` form when you don't own the schema (e.g. it comes from a third-party module) or when defining a small DTO with an inline schema, where chaining `.meta()` on the inline expression hurts readability.
|
package/dist/index.js
CHANGED
|
@@ -1063,13 +1063,22 @@ var normalizeZodNestOptions = /* @__PURE__ */ __name((opts) => {
|
|
|
1063
1063
|
// src/pipes/validation.pipe.ts
|
|
1064
1064
|
function _ts_decorate(decorators, target, key, desc) {
|
|
1065
1065
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1066
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1067
|
-
|
|
1066
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1067
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1068
|
+
} else {
|
|
1069
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1070
|
+
if (d = decorators[i]) {
|
|
1071
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1068
1075
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1069
1076
|
}
|
|
1070
1077
|
__name(_ts_decorate, "_ts_decorate");
|
|
1071
|
-
function _ts_metadata(
|
|
1072
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
1078
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
1079
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1080
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1081
|
+
}
|
|
1073
1082
|
}
|
|
1074
1083
|
__name(_ts_metadata, "_ts_metadata");
|
|
1075
1084
|
function _ts_param(paramIndex, decorator) {
|
|
@@ -1728,13 +1737,22 @@ var ZodCookies = /* @__PURE__ */ __name((schema, options) => {
|
|
|
1728
1737
|
}, "ZodCookies");
|
|
1729
1738
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
1730
1739
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1731
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1732
|
-
|
|
1740
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1741
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1742
|
+
} else {
|
|
1743
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1744
|
+
if (d = decorators[i]) {
|
|
1745
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1733
1749
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1734
1750
|
}
|
|
1735
1751
|
__name(_ts_decorate2, "_ts_decorate");
|
|
1736
|
-
function _ts_metadata2(
|
|
1737
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
1752
|
+
function _ts_metadata2(metadataKey, metadataValue) {
|
|
1753
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1754
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1755
|
+
}
|
|
1738
1756
|
}
|
|
1739
1757
|
__name(_ts_metadata2, "_ts_metadata");
|
|
1740
1758
|
function _ts_param2(paramIndex, decorator) {
|