generated at
Zod

v3まででてる
開発者は@colinhacks










必須ってどうやって定義するの
defaultで必須で、任意の時にoptional()をつけるのか



zod.arrayやzod.stringではzod.nonempty()が使える
後者、何故かdocsに書いてない


ts型定義をzodに変換する
vscode

以下のどれで定義するのかを指標が欲しいな
普通にtype
value as const
zod
infer typeするのが面倒jjk



.optional() とか .nullable() だったものを、通常の T に戻す
ts
const stringSchema = z.string(); const nullableString = stringSchema.nullable(); nullableString.unwrap() === stringSchema; // true

docsよみ(読んだら消す)
Coercion for primitives
Literals
NaNs
Booleans
Dates
.keyof
.merge
.pick/.omit
.partial
.deepPartial
.passthrough
.strict
.strip
.catchall
Arrays
.element
.nonempty
.min/.max/.length
Tuples
Records
Maps
Sets
Intersections
Recursive types
JSON type
Cyclical data
Promises
Instanceof
Functions
Preprocess
Schema methods
.superRefine
.array
.promise
.and
Guides and concepts
Type inference
Writing generic functions