API reference > @kontsedal/olas-zod > ZodToLeaf
ZodToLeaf type
Recursively map a Zod schema to its Olas form leaf: - ZodObject<S> → Form<{ [K]: ZodToLeaf<S[K]> }> - ZodArray<E> → FieldArray<ZodToLeaf<E>> (when E is object/array) or FieldArray<Field<infer<E>>> for primitive elements. - everything else → Field<infer<S>>.
ZodToLeaf<S> matches what buildLeaf(ctx, s, ...) returns at runtime, so the public createZodForm<T> can publish a precise structural type without the consumer needing a hand-written CardForm = Form<{...}> cast.
Signature:
typescript
export type ZodToLeaf<S> = UnwrapZod<S> extends z.ZodObject<infer RawShape> ? Form<{ [K in keyof RawShape]: ZodToLeaf<RawShape[K]>; }> : UnwrapZod<S> extends z.ZodArray<infer Element> ? FieldArray<ZodToLeaf<Element> extends Form<any> | Field<any> ? ZodToLeaf<Element> : never> : Field<z.infer<UnwrapZod<S> & z.ZodType>>;References: UnwrapZod, Form, ZodToLeaf, FieldArray, Field