Expand description
§vld-ts — Generate TypeScript Zod schemas from JSON Schema
Converts JSON Schemas (as produced by vld’s json_schema() methods)
into TypeScript Zod schema code.
§Example
use vld_ts::json_schema_to_zod;
let schema = serde_json::json!({
"type": "object",
"required": ["name", "email"],
"properties": {
"name": {"type": "string", "minLength": 2, "maxLength": 50},
"email": {"type": "string", "format": "email"},
"age": {"type": "integer", "minimum": 0}
}
});
let ts = json_schema_to_zod(&schema);
assert!(ts.contains("z.object("));
assert!(ts.contains("z.string()"));Functions§
- generate_
zod_ file - Generate named Zod schemas for multiple types.
- json_
schema_ to_ zod - Convert a JSON Schema to TypeScript Zod schema code.