Function value

  • The value schema validates that the input is exactly any given literal value. This schema allows you to verify the values undefined and null, as well as any other literal primitive value.

    Example

    import { value } from "typerun/schema";
    import { is } from "typerun";

    if (is(value(true))(true)) {
    console.log("true is true");
    }

    if (!is(value(true))(false)) {
    console.log("false is not true");
    }

    if (!is(value(undefined))(null)) {
    console.log("null is not undefined");
    }

    Type Parameters

    • R extends undefined | null | string | number | bigint | boolean | symbol

    Parameters

    • value: R

      The literal value to validate.

    Returns Schema<R>