Skip to content

Records & Validation

Validate each field with its own lens. Short-circuits on first failure.

(bend.record { name = bend.str; age = bend.int; }).get { name = "alice"; age = 30; }
# right { name = "alice"; age = 30; }

Validate every field; gather all failures into per-field Either values.

(bend.recordAll { name = bend.str; age = bend.int; }).get { name = "alice"; age = "thirty"; }
# left { name = right "alice"; age = left { field = "age"; got = "thirty"; }; }

Like recordAll but f field got shapes each failure.

(bend.recordAllWith (field: got: "${field}: expected ${builtins.typeOf got}") { age = bend.int; }).get { age = "x"; }
# left { age = left "age: expected string"; }

Default error shape used by recordAll: { inherit field got; }.

Contribute Community Sponsor