zod_gen 1.1.19

Generate Zod schemas and TypeScript types from Rust types. Use with zod_gen_derive for automatic #[derive(ZodSchema)] support and serde rename compatibility.
Documentation

zod_gen

Crates.io Documentation

Core library for generating Zod schemas from Rust types.

Features

  • ZodSchema trait for defining schemas
  • Helper functions for building Zod expressions
  • ZodGenerator for batch file generation
  • Built-in implementations for primitive types

Usage

use zod_gen::{ZodSchema, zod_object, zod_string, zod_number};

struct User {
    id: u64,
    name: String,
}

impl ZodSchema for User {
    fn type_name() -> String { "User".to_string() }
    fn zod_schema() -> String {
        zod_object(&[
            ("id", zod_number()),
            ("name", zod_string()),
        ])
    }
}

For more examples and documentation, see the main repository.