Function isErr

  • Check if a result is failed.

    Example

    import { isErr } from "typerun/result";
    import { string } from "typerun/schema";
    import { validate } from "typerun";

    const result = validate(string)(42);

    if (isErr(result)) {
    console.log(result.errors); // [{ name: "ValidationError", message: "Value `42` is not a string" }]
    } else {
    console.log(result.data);
    }

    Type Parameters

    • E

    Parameters

    Returns result is Err<E>