@tempots/std

Validation variable

Utility functions for working with Validation types.

Signature:

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