Type alias ValidationResult<T, E>

ValidationResult<T, E>: {
    data: T;
    success: true;
} | {
    error: E;
    success: false;
}

A discriminated union type representing the result of an operation that can succeed or fail. This provides a functional approach to error handling without throwing exceptions.

Type Parameters

  • T
  • E = string

Type declaration

  • data: T
  • success: true

Type declaration

  • error: E
  • success: false