Skip to content

Commit fc1e556

Browse files
committed
Fixes #5073
1 parent 1cebf33 commit fc1e556

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

packages/zod/src/v4/core/schemas.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,7 +1721,7 @@ export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$con
17211721
const _normalized = util.cached(() => {
17221722
const keys = Object.keys(def.shape);
17231723
for (const k of keys) {
1724-
if (!(def.shape[k] instanceof $ZodType)) {
1724+
if (!def.shape[k]._zod.traits.has("$ZodType")) {
17251725
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
17261726
}
17271727
}
@@ -3642,7 +3642,8 @@ export const $ZodTemplateLiteral: core.$constructor<$ZodTemplateLiteral> = /*@__
36423642
$ZodType.init(inst, def);
36433643
const regexParts: string[] = [];
36443644
for (const part of def.parts) {
3645-
if (part instanceof $ZodType) {
3645+
if (typeof part === "object" && part !== null) {
3646+
// is Zod schema
36463647
if (!part._zod.pattern) {
36473648
// if (!source)
36483649
throw new Error(`Invalid template literal part, no pattern found: ${[...(part as any)._zod.traits].shift()}`);

play.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@ import { z } from "zod/v4";
22

33
z;
44

5-
console.log(
6-
z
7-
.object({
8-
a: z.string(),
9-
})
10-
.transform((data) => {
11-
return {
12-
...data,
13-
tx: true,
14-
};
15-
})
16-
.safeParse({ a: "1" })
17-
);
5+
// import { z } from "zod";
6+
const BrandedSchema = z.string().brand<"brand">();
7+
const WrappedSchema = z.object({ key: BrandedSchema });
8+
9+
type bso = typeof BrandedSchema._output;
10+
type basdfasdfso = typeof BrandedSchema._zod.output;
11+
type wso = (typeof WrappedSchema._output)["key"];
12+
type bso2 = z.output<typeof BrandedSchema>;
13+
type wso2 = z.output<typeof WrappedSchema>["key"];

0 commit comments

Comments
 (0)