Skip to main content

@remotion/zod-types-v3v4.0.426

@remotion/zod-types 自 Remotion v4.0.426 起使用 Zod v4 创建模式。

此包适用于如果你正在使用 Zod v3.22.3 并且想要将函数如 zColor() 与 Zod v3.22.3 模式组合使用的情况。

🌐 This package is for if you are using Zod v3.22.3 and want to compose functions like zColor() with Zod v3.22.3 schemas.

安装

🌐 Installation

npx remotion add @remotion/zod-types-v3

用法

🌐 Usage

Using @remotion/zod-types-v3 with Zod v3
import {z} from 'zod'; // zod = 3.22.3 import {zColor} from '@remotion/zod-types-v3'; export const mySchema = z.object({ color: zColor(), });

该包导出与 @remotion/zod-types 相同的 zColor()zTextarea()zMatrix() 函数,但它们返回 Zod v3.22.3 架构类型。

🌐 The package exports the same zColor(), zTextarea(), and zMatrix() functions as @remotion/zod-types, but they return Zod v3.22.3 schema types.

何时使用

🌐 When to use

在 Zod v4 中使用 @remotion/zod-types

🌐 Use @remotion/zod-types with Zod v4:

import {z} from 'zod'; // zod = 4.x.x
import {zColor} from '@remotion/zod-types';

export const mySchema = z.object({
  color: zColor(),
});

如果你没有嵌套模式,请使用 @remotion/zod-types:

🌐 Use @remotion/zod-types if you are not nesting schemas:

import {zColor} from '@remotion/zod-types';
import {visualControl} from '@remotion/studio';

export const myVisualControl = visualControl('my-color', '#fff', zColor());

在 Zod v3.22.3 中使用 @remotion/zod-types-v3

🌐 Use @remotion/zod-types-v3 with Zod v3.22.3:

import {z} from 'zod'; // zod = 3.22.3
import {zColor} from '@remotion/zod-types-v3';

export const mySchema = z.object({
  color: zColor(),
});

其他 Zod 3.x.x 版本不受官方支持。

🌐 Other Zod 3.x.x versions are not officially supported.

另请参阅

🌐 See also