Function both

  • Combine two validators with a logical AND

    Type Parameters

    • T

      The first validated type

    • U

      The second validated type

    Parameters

    Returns Validator<T & U>

    Example

    const isNonEmptyStringArray = both(isNonEmptyArray, isStringArray);

    isNonEmptyStringArray([""]) >>
    {
    valid: true,
    parsed: [""],
    };

    isNonEmptyStringArray([]) >>
    {
    valid: false,
    error: "Not a non empty array: []",
    };

    isNonEmptyStringArray([1]) >>
    {
    valid: false,
    error: "Not an array of strings: [1]",
    };