Function not

  • Invert a validator

    Type Parameters

    • T

      The validated type

    Parameters

    • validator: Validator<T>

      The validator to invert

    • Optional reason: string

      The failure explanation

    Returns Validator<unknown>

    Example

    const isNotNull = not(isNull, "Is null");

    isNotNull(null).error >>
    {
    valid: false,
    error: "Is null: null",
    };