Derived from your types
Your records, variants and recursive types are the contract, their bounds and docs included.
Strict, light and derived from your types. Built for JSON Schema, Zod and Melange.
opam repo add hypha https://github.com/hyphatech/opam-repository.gitopam install wiretype ppx_wiretypetype line = { sku : string; quantity : int; [@min 1] [@max 99] (** how many *) note : string option; [@max_length 200]}[@@deriving wiretype](** A line of an order. *)module J = Wiretype
let () = match J.decode Line.line_json {|{"sku": "A1", "quantity": 120, "note": 7}|} with | Ok _ -> () | Error problems -> List.iter (fun p -> print_endline (J.Problem.to_string p)) problemsYour records, variants and recursive types are the contract, their bounds and docs included.
Invalid input is refused with every mistake, each at its path with a code a client can act on.
One walk prints all three, and the Zod and the Melange module are held to the server’s verdict on every test run, so a form finds what is wrong before it sends.