One schema
One lingoObject for a tool argument and a human form.
Prefer the live demos? Open this section in the interactive docs.
Use one lingoObject to validate an LLM tool argument and canonicalize a human form, unchanged.
const shipment = lingoObject({
weight: quantityField({ kind: 'mass', unit: 'kg', min: 0 }),
deliverBy: dateField(),
})import { tool } from 'ai'
// LLM emits "5 kg" / "next friday"; canonical on arrival
tool({ inputSchema: shipment, execute: run })import { standardSchemaResolver } from '@hookform/resolvers/standard-schema'
// user types "5 kg" / picks a date; canonical on submit
useForm({ resolver: standardSchemaResolver(shipment) })Type 5'11" or emit "5 kg"; both arrive canonical. (Whole-form resolvers use lingoObject(shape, { passthrough: true }) for fields lingo doesn't own.)
A column is a schema
The same field works per table column. Attach a quantityField to a column and every cell accepts whatever people paste — 3 lb 4 oz, 1,2 kg, 72°F — while the column keeps one canonical unit, so a totals row can add plain numbers. safeParse returns the canonical value plus any warnings (UNIT_ASSUMED, AMBIGUOUS_UNIT), so a grid can flag assumptions instead of hiding them.