Skip to content

TaskValidation

TaskValidation<E, A> = Task<Validation<E, A>>

Defined in: Core/TaskValidation.ts:34

A Task that resolves to a Validation — combining async operations with error accumulation. Unlike Task.Result, multiple failures are collected rather than short-circuiting on the first error.

E

A

const validateName = (name: string): Task.Validation<string, string> =>
  name.length > 0
    ? Task.Validation.passed(name)
    : Task.Validation.failed("Name is required");

// Accumulate errors from multiple async validations using ap
pipe(
  Task.Validation.passed((name: string) => (age: number) => ({ name, age })),
  Task.Validation.ap(validateName("")),
  Task.Validation.ap(validateAge(-1))
)();
// Failed(["Name is required", "Age must be positive"])