Check if a result is failed.
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);} Copy
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);}
The result to check.
Check if a result is failed.
Example