Records & Validation
record { k = lens; ... }
Section titled “record { k = lens; ... }”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; }recordAll { k = lens; ... }
Section titled “recordAll { k = lens; ... }”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"; }; }recordAllWith f { k = lens; ... }
Section titled “recordAllWith f { k = lens; ... }”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"; }defaultRecordError field got
Section titled “defaultRecordError field got”Default error shape used by recordAll: { inherit field got; }.