Skip to content

struct

struct<E, R>(fields): Validation<E, R>

Defined in: Core/Validation.ts:395

Combines a record of Validations into a single Validation of a record. Accumulates all failed branches’ errors.

E

R extends Record<string, any>

{ [K in string | number | symbol]: Validation<E, R[K]> }

Validation<E, R>

Validation.struct({
  name: Validation.passed("Alice"),
  age: Validation.passed(30)
}); // Passed({ name: "Alice", age: 30 })

Validation.struct({
  name: Validation.failed("Name required"),
  age: Validation.failed("Age must be >= 0")
}); // Failed(["Name required", "Age must be >= 0"])