Skip to content

🎥 Make videos programmatically with React

Support standalone zod v3 (3.22.x) schemas in AnyZodObject

Jonny Burger8eb3a62110f4
diff --git a/bun.lock b/bun.lock
index c7547deb94..ec3f0c6462 100644
--- a/bun.lock
+++ b/bun.lock
@@ -1164,7 +1164,7 @@
"version": "4.0.423",
"dependencies": {
"remotion": "workspace:*",
- "zod": "catalog:",
+ "zod": "3.22.3",
},
"devDependencies": {
"@remotion/eslint-config-internal": "workspace:*",
@@ -8892,6 +8892,8 @@
"@remotion/react18-tests/react-dom": ["[email protected]", "", { "dependencies": { "loose-envify": "1.4.0", "scheduler": "0.23.2" }, "peerDependencies": { "react": "18.3.1" } }, "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw=="],
+ "@remotion/react18-tests/zod": ["[email protected]", "", {}, "sha512-EjIevzuJRiRPbVH4mGc8nApb/lVLKVpmUhAaR5R5doKGfAnGJ6Gr3CViAVjP+4FWSxCsybeWQdcgCtbX+7oZug=="],
+
"@remotion/renderer/source-map": ["[email protected]", "", { "dependencies": { "whatwg-url": "7.1.0" } }, "sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA=="],
"@remotion/tailwind/tailwindcss": ["[email protected]", "", { "dependencies": { "@alloc/quick-lru": "5.2.0", "arg": "5.0.2", "chokidar": "3.5.3", "didyoumean": "1.2.2", "dlv": "1.1.3", "fast-glob": "3.3.2", "glob-parent": "6.0.2", "is-glob": "4.0.3", "jiti": "1.21.6", "lilconfig": "2.1.0", "micromatch": "4.0.8", "normalize-path": "3.0.0", "object-hash": "3.0.0", "picocolors": "1.1.1", "postcss": "8.5.1", "postcss-import": "15.1.0", "postcss-js": "4.0.1", "postcss-load-config": "4.0.1", "postcss-nested": "6.0.1", "postcss-selector-parser": "6.1.1", "resolve": "1.22.8", "sucrase": "3.32.0" }, "bin": { "tailwind": "lib/cli.js", "tailwindcss": "lib/cli.js" } }, "sha512-KqjHOJKogOUt5Bs752ykCeiwvi0fKVkr5oqsFNt/8px/tA8scFPIlkygsf6jXrfCqGHz7VflA6+yytWuM+XhFw=="],
diff --git a/packages/core/src/any-zod-type.ts b/packages/core/src/any-zod-type.ts
index 978b721fbe..89350e8a32 100644
--- a/packages/core/src/any-zod-type.ts
+++ b/packages/core/src/any-zod-type.ts
@@ -1,4 +1,14 @@
import type * as z3 from 'zod/v3';
import type * as z4 from 'zod/v4/core';
-export type AnyZodObject = z3.AnyZodObject | z4.$ZodObject;
+/**
+ * Structural type for standalone zod v3 (e.g. 3.22.x) ZodObject,
+ * which predates Standard Schema and lacks ~standard/~validate.
+ */
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+type StandaloneZodV3Object = {_def: any; _input: any; [k: string]: any};
+
+export type AnyZodObject =
+ | z3.AnyZodObject
+ | z4.$ZodObject
+ | StandaloneZodV3Object;
diff --git a/packages/example/src/Root.tsx b/packages/example/src/Root.tsx
index 3bb285aaf3..0e4c3aaa3c 100644
--- a/packages/example/src/Root.tsx
+++ b/packages/example/src/Root.tsx
@@ -1520,11 +1520,10 @@ export const Index: React.FC = () => {
defaultProps={{
greeting: 'Hello from Zod v4!',
count: 42,
- enabled: true,
- items: [{label: 'alpha', value: 1}],
- mode: 'dark' as const,
- optional: undefined,
- nested: {a: 'hello', b: 99},
+ enabled: false,
+ items: [{label: 'alpha!', value: 1}],
+ mode: 'light' as const,
+ nested: {a: 'asdfadsf', b: 99},
}}
/>
</Folder>
diff --git a/packages/example/src/ZodV4SchemaTest.tsx b/packages/example/src/ZodV4SchemaTest.tsx
index 52e71561df..d1df194b74 100644
--- a/packages/example/src/ZodV4SchemaTest.tsx
+++ b/packages/example/src/ZodV4SchemaTest.tsx
@@ -4,7 +4,7 @@
*/
import React from 'react';
import {AbsoluteFill} from 'remotion';
-import {z} from 'zod';
+import {z} from 'zod/v4';
export const zodV4Schema = z.object({
greeting: z.string().default('Hello from Zod v4!'),
diff --git a/packages/react18-tests/package.json b/packages/react18-tests/package.json
index c9f7011203..5f811e64c5 100644
--- a/packages/react18-tests/package.json
+++ b/packages/react18-tests/package.json
@@ -17,7 +17,7 @@
"license": "UNLICENSED",
"dependencies": {
"remotion": "workspace:*",
- "zod": "catalog:"
+ "zod": "3.22.3"
},
"devDependencies": {
"@remotion/eslint-config-internal": "workspace:*",
diff --git a/packages/react18-tests/src/test/ZodV3SchemaTest.tsx b/packages/react18-tests/src/test/ZodV3SchemaTest.tsx
index 3e2c720117..f652ac4b2d 100644
--- a/packages/react18-tests/src/test/ZodV3SchemaTest.tsx
+++ b/packages/react18-tests/src/test/ZodV3SchemaTest.tsx
@@ -3,7 +3,7 @@
* Verifies that the studio schema editor works with zod v3 schemas.
*/
import React from 'react';
-import {z} from 'zod/v3';
+import {z} from 'zod';
export const zodV3Schema = z.object({
title: z.string(),