@tempots/std

Validation variable

Utility functions for working with Validation types.

Signature:

Validation: {
    valid: {
        type: "valid";
    };
    invalid(error: E): Validation;
    isValid(r: Validation): r is Valid;
    isInvalid(r: Validation): r is Invalid;
    match: (r: Validation, valid: () => V, invalid: (error: E) => V) => V;
    toResult: (validation: Validation, value: T) => Result;
    whenValid: (r: Validation, apply: () => void) => Validation;
    whenInvalid: (r: Validation, apply: (e: E) => void) => Validation;
}