typeshift 0.5.1

Zod-like parse, validation, and JSON Schema flow for Rust types
Documentation
use typeshift::typeshift;

#[typeshift]
#[derive(Debug)]
struct User {
    #[validate(length(min = 3))]
    name: String,
}

#[typeshift]
#[derive(Debug)]
struct Envelope<T> {
    payload: T,
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let envelope: Envelope<User> = typeshift::parse_str(r#"{"payload":{"name":"Ada"}}"#)?;
    let json = typeshift::to_json(&envelope)?;

    println!("envelope: {envelope:?}");
    println!("json: {json}");

    Ok(())
}