Commit 5ab0f69
chore(deps): update dependency zod to v4.3.2 (#3156)
This PR contains the following updates:
| Package | Change |
[Age](https://docs.renovatebot.com/merge-confidence/) |
[Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [zod](https://zod.dev)
([source](https://redirect.github.com/colinhacks/zod)) | [`4.2.1` →
`4.3.2`](https://renovatebot.com/diffs/npm/zod/4.2.1/4.3.2) |

|

|
---
### Release Notes
<details>
<summary>colinhacks/zod (zod)</summary>
###
[`v4.3.2`](https://redirect.github.com/colinhacks/zod/compare/v4.3.1...0f41e5a12a43e6913c9dcb501b2b5136ea86500d)
[Compare
Source](https://redirect.github.com/colinhacks/zod/compare/v4.3.1...v4.3.2)
###
[`v4.3.1`](https://redirect.github.com/colinhacks/zod/releases/tag/v4.3.1)
[Compare
Source](https://redirect.github.com/colinhacks/zod/compare/v4.3.0...v4.3.1)
#### Commits:
-
[`0fe8840`](https://redirect.github.com/colinhacks/zod/commit/0fe88407a4149c907929b757dc6618d8afe998fc)
allow non-overwriting extends with refinements. 4.3.1
###
[`v4.3.0`](https://redirect.github.com/colinhacks/zod/releases/tag/v4.3.0)
[Compare
Source](https://redirect.github.com/colinhacks/zod/compare/v4.2.1...v4.3.0)
This is Zod's biggest release since 4.0. It addresses several of Zod's
longest-standing feature requests.
#### `z.fromJSONSchema()`
Convert JSON Schema to Zod
([#​5534](https://redirect.github.com/colinhacks/zod/pull/5534),
[#​5586](https://redirect.github.com/colinhacks/zod/pull/5586))
You can now convert JSON Schema definitions directly into Zod schemas.
This function supports JSON Schema `"draft-2020-12"`, `"draft-7"`,
`"draft-4"`, and OpenAPI 3.0.
```typescript
import * as z from "zod";
const schema = z.fromJSONSchema({
type: "object",
properties: {
name: { type: "string", minLength: 1 },
age: { type: "integer", minimum: 0 },
},
required: ["name"],
});
schema.parse({ name: "Alice", age: 30 }); // ✅
```
The API should be considered experimental. There are no guarantees of
1:1 "round-trip soundness": `MySchema` > `z.toJSONSchema()` >
`z.fromJSONSchema()`. There are several features of Zod that don't exist
in JSON Schema and vice versa, which makes this virtually impossible.
Features supported:
- All primitive types (`string`, `number`, `integer`, `boolean`, `null`,
`object`, `array`)
- String formats (`email`, `uri`, `uuid`, `date-time`, `date`, `time`,
`ipv4`, `ipv6`, and more)
- Composition (`anyOf`, `oneOf`, `allOf`)
- Object constraints (`additionalProperties`, `patternProperties`,
`propertyNames`)
- Array constraints (`prefixItems`, `items`, `minItems`, `maxItems`)
- `$ref` for local references and circular schemas
- Custom metadata is preserved
#### `z.xor()` — exclusive union
([#​5534](https://redirect.github.com/colinhacks/zod/pull/5534))
A new exclusive union type that requires **exactly one** option to
match. Unlike `z.union()` which passes if *any* option matches,
`z.xor()` fails if zero or more than one option matches.
```typescript
const schema = z.xor([z.string(), z.number()]);
schema.parse("hello"); // ✅
schema.parse(42); // ✅
schema.parse(true); // ❌ zero matches
```
When converted to JSON Schema, `z.xor()` produces `oneOf` instead of
`anyOf`.
#### `z.looseRecord()` — partial record validation
([#​5534](https://redirect.github.com/colinhacks/zod/pull/5534))
A new record variant that only validates keys matching the key schema,
passing through non-matching keys unchanged. This is used to represent
`patternProperties` in JSON Schema.
```typescript
const schema = z.looseRecord(z.string().regex(/^S_/), z.string());
schema.parse({ S_name: "John", other: 123 });
// ✅ { S_name: "John", other: 123 }
// only S_name is validated, "other" passes through
```
#### `.exactOptional()` — strict optional properties
([#​5589](https://redirect.github.com/colinhacks/zod/pull/5589))
A new wrapper that makes a property *key-optional* (can be omitted) but
does **not** accept `undefined` as an explicit value.
```typescript
const schema = z.object({
a: z.string().optional(), // accepts `undefined`
b: z.string().exactOptional(), // does not accept `undefined`
});
schema.parse({}); // ✅
schema.parse({ a: undefined }); // ✅
schema.parse({ b: undefined }); // ❌
```
This makes it possible to accurately represent the full spectrum of
optionality expressible using
[`exactOptionalPropertyTypes`](https://www.typescriptlang.org/tsconfig/exactOptionalPropertyTypes.html).
#### `.apply()`
A utility method for applying arbitrary transformations to a schema,
enabling cleaner schema composition.
([#​5463](https://redirect.github.com/colinhacks/zod/pull/5463))
```typescript
const setCommonChecks = <T extends z.ZodNumber>(schema: T) => {
return schema.min(0).max(100);
};
const schema = z.number().apply(setCommonChecks).nullable();
```
#### `.brand()` cardinality
The `.brand()` method now accepts a second argument to control whether
the brand applies to input, output, or both. Closes
[#​4764](https://redirect.github.com/colinhacks/zod/issues/4764),
[#​4836](https://redirect.github.com/colinhacks/zod/issues/4836).
```typescript
// output only (default)
z.string().brand<"UserId">(); // output is branded (default)
z.string().brand<"UserId", "out">(); // output is branded
z.string().brand<"UserId", "in">(); // input is branded
z.string().brand<"UserId", "inout">(); // both are branded
```
#### Type predicates on `.refine()`
([#​5575](https://redirect.github.com/colinhacks/zod/pull/5575))
The `.refine()` method now supports type predicates to narrow the output
type:
```typescript
const schema = z.string().refine((s): s is "a" => s === "a");
type Input = z.input<typeof schema>; // string
type Output = z.output<typeof schema>; // "a"
```
#### `ZodMap` methods: `min`, `max`, `nonempty`, `size`
([#​5316](https://redirect.github.com/colinhacks/zod/pull/5316))
`ZodMap` now has parity with `ZodSet` and `ZodArray`:
```typescript
const schema = z.map(z.string(), z.number())
.min(1)
.max(10)
.nonempty();
schema.size; // access the size constraint
```
#### `.with()` alias for `.check()`
([359c0db](https://redirect.github.com/colinhacks/zod/commit/359c0db6))
A new `.with()` method has been added as a more readable alias for
`.check()`. Over time, more APIs have been added that don't qualify as
"checks". The new method provides a readable alternative that doesn't
muddy semantics.
```typescript
z.string().with(
z.minLength(5),
z.toLowerCase()
);
// equivalent to:
z.string().check(
z.minLength(5),
z.trim(),
z.toLowerCase()
);
```
##### `z.slugify()` transform
Transform strings into URL-friendly slugs. Works great with `.with()`:
```typescript
// Zod
z.string().slugify().parse("Hello World"); // "hello-world"
// Zod Mini
// using .with() for explicit check composition
z.string().with(z.slugify()).parse("Hello World"); // "hello-world"
```
#### `z.meta()` and `z.describe()` in Zod Mini
([947b4eb](https://redirect.github.com/colinhacks/zod/commit/947b4eb2))
Zod Mini now exports `z.meta()` and `z.describe()` as top-level
functions for adding metadata to schemas:
```typescript
import * as z from "zod/mini";
// add description
const schema = z.string().with(
z.describe("A user's name"),
);
// add arbitrary metadata
const schema2 = z.number().with(
z.meta({ deprecated: true })
);
```
#### New locales
- Armenian (`am`)
([#​5531](https://redirect.github.com/colinhacks/zod/pull/5531))
- Uzbek (`uz`)
([#​5519](https://redirect.github.com/colinhacks/zod/pull/5519))
```ts
import * as z from "zod";
import { uz } from "zod/locales";
z.config(uz());
```
<br/><br/>
***
<br/><br/>
#### Bug fixes
All of these changes fix soundness issues in Zod. As with any bug fix
there's some chance of breakage if you were intentionally or
unintentionally relying on this unsound behavior.
##### 1 parent 1115157 commit 5ab0f69
File tree
6 files changed
+121
-61
lines changed- example
- express-zod-api/tests
- __snapshots__
6 files changed
+121
-61
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
136 | | - | |
137 | 135 | | |
138 | 136 | | |
| 137 | + | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
147 | 148 | | |
148 | 149 | | |
149 | | - | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| 161 | + | |
| 162 | + | |
161 | 163 | | |
162 | 164 | | |
| 165 | + | |
163 | 166 | | |
164 | 167 | | |
165 | | - | |
166 | 168 | | |
167 | 169 | | |
168 | | - | |
169 | | - | |
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
208 | 209 | | |
209 | 210 | | |
210 | | - | |
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
| 278 | + | |
| 279 | + | |
278 | 280 | | |
279 | 281 | | |
280 | 282 | | |
281 | | - | |
282 | | - | |
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
| |||
868 | 868 | | |
869 | 869 | | |
870 | 870 | | |
871 | | - | |
872 | 871 | | |
873 | 872 | | |
874 | 873 | | |
| |||
880 | 879 | | |
881 | 880 | | |
882 | 881 | | |
| 882 | + | |
883 | 883 | | |
884 | 884 | | |
885 | 885 | | |
| |||
Lines changed: 26 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2091 | 2091 | | |
2092 | 2092 | | |
2093 | 2093 | | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
2094 | 2097 | | |
2095 | 2098 | | |
2096 | 2099 | | |
| |||
3594 | 3597 | | |
3595 | 3598 | | |
3596 | 3599 | | |
3597 | | - | |
3598 | 3600 | | |
| 3601 | + | |
3599 | 3602 | | |
3600 | 3603 | | |
3601 | 3604 | | |
| |||
3653 | 3656 | | |
3654 | 3657 | | |
3655 | 3658 | | |
3656 | | - | |
3657 | 3659 | | |
| 3660 | + | |
3658 | 3661 | | |
3659 | 3662 | | |
3660 | 3663 | | |
| |||
3713 | 3716 | | |
3714 | 3717 | | |
3715 | 3718 | | |
3716 | | - | |
3717 | | - | |
3718 | | - | |
3719 | | - | |
3720 | | - | |
3721 | 3719 | | |
3722 | 3720 | | |
3723 | 3721 | | |
| |||
3728 | 3726 | | |
3729 | 3727 | | |
3730 | 3728 | | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
| 3733 | + | |
3731 | 3734 | | |
3732 | 3735 | | |
3733 | 3736 | | |
| |||
3933 | 3936 | | |
3934 | 3937 | | |
3935 | 3938 | | |
3936 | | - | |
3937 | | - | |
3938 | 3939 | | |
3939 | 3940 | | |
3940 | 3941 | | |
3941 | 3942 | | |
3942 | 3943 | | |
3943 | 3944 | | |
3944 | 3945 | | |
| 3946 | + | |
| 3947 | + | |
3945 | 3948 | | |
3946 | 3949 | | |
3947 | 3950 | | |
| |||
4013 | 4016 | | |
4014 | 4017 | | |
4015 | 4018 | | |
| 4019 | + | |
4016 | 4020 | | |
4017 | 4021 | | |
4018 | | - | |
4019 | 4022 | | |
| 4023 | + | |
4020 | 4024 | | |
4021 | 4025 | | |
4022 | | - | |
4023 | 4026 | | |
4024 | 4027 | | |
4025 | 4028 | | |
| |||
4044 | 4047 | | |
4045 | 4048 | | |
4046 | 4049 | | |
| 4050 | + | |
4047 | 4051 | | |
4048 | 4052 | | |
4049 | | - | |
4050 | 4053 | | |
4051 | 4054 | | |
4052 | 4055 | | |
| |||
4137 | 4140 | | |
4138 | 4141 | | |
4139 | 4142 | | |
4140 | | - | |
4141 | | - | |
4142 | 4143 | | |
4143 | 4144 | | |
4144 | 4145 | | |
4145 | 4146 | | |
4146 | 4147 | | |
4147 | 4148 | | |
4148 | 4149 | | |
| 4150 | + | |
| 4151 | + | |
4149 | 4152 | | |
4150 | 4153 | | |
4151 | 4154 | | |
| |||
4254 | 4257 | | |
4255 | 4258 | | |
4256 | 4259 | | |
4257 | | - | |
4258 | | - | |
4259 | 4260 | | |
4260 | 4261 | | |
4261 | 4262 | | |
4262 | 4263 | | |
4263 | 4264 | | |
4264 | 4265 | | |
4265 | 4266 | | |
| 4267 | + | |
| 4268 | + | |
4266 | 4269 | | |
4267 | 4270 | | |
4268 | 4271 | | |
| |||
4332 | 4335 | | |
4333 | 4336 | | |
4334 | 4337 | | |
| 4338 | + | |
4335 | 4339 | | |
4336 | 4340 | | |
4337 | | - | |
4338 | 4341 | | |
4339 | 4342 | | |
4340 | 4343 | | |
| |||
4407 | 4410 | | |
4408 | 4411 | | |
4409 | 4412 | | |
| 4413 | + | |
4410 | 4414 | | |
4411 | 4415 | | |
4412 | | - | |
4413 | 4416 | | |
4414 | 4417 | | |
4415 | 4418 | | |
| |||
4451 | 4454 | | |
4452 | 4455 | | |
4453 | 4456 | | |
| 4457 | + | |
4454 | 4458 | | |
4455 | 4459 | | |
4456 | | - | |
4457 | 4460 | | |
4458 | 4461 | | |
4459 | 4462 | | |
| |||
4553 | 4556 | | |
4554 | 4557 | | |
4555 | 4558 | | |
4556 | | - | |
4557 | 4559 | | |
| 4560 | + | |
4558 | 4561 | | |
4559 | 4562 | | |
4560 | 4563 | | |
| |||
4570 | 4573 | | |
4571 | 4574 | | |
4572 | 4575 | | |
4573 | | - | |
4574 | 4576 | | |
4575 | 4577 | | |
4576 | 4578 | | |
| 4579 | + | |
4577 | 4580 | | |
4578 | 4581 | | |
4579 | 4582 | | |
| |||
4617 | 4620 | | |
4618 | 4621 | | |
4619 | 4622 | | |
4620 | | - | |
4621 | 4623 | | |
| 4624 | + | |
4622 | 4625 | | |
4623 | 4626 | | |
4624 | 4627 | | |
| |||
5029 | 5032 | | |
5030 | 5033 | | |
5031 | 5034 | | |
5032 | | - | |
5033 | 5035 | | |
5034 | 5036 | | |
5035 | 5037 | | |
5036 | 5038 | | |
5037 | 5039 | | |
| 5040 | + | |
5038 | 5041 | | |
5039 | 5042 | | |
5040 | 5043 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
| |||
171 | 175 | | |
172 | 176 | | |
173 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
174 | 184 | | |
175 | 185 | | |
176 | 186 | | |
| |||
209 | 219 | | |
210 | 220 | | |
211 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
212 | 226 | | |
213 | 227 | | |
214 | 228 | | |
| |||
Lines changed: 41 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
4 | 44 | | |
5 | 45 | | |
6 | 46 | | |
| |||
0 commit comments