Validates that one of the given validators pass.

If all validators fail, the validator that produced an error at the deepest path will have its error message bubbled. If all validators failed at the current depth, a concatenation of validator descriptions will be used.

For example: orValidators(number(), string()).validate(false) will produce the message: 'Expected (number | string), but was false, At: '

And: orValidators(number(), object({ childProp: number() })).validate({ childProp: 'not-a-number' }) will produce: 'Expected number, but was "not-a-number", At: childProp'

The validators to test.

  • Validates that one of the given validators pass.

    Type Parameters

    • A
    • B

    Parameters

    Returns Validator<A | B, any>

  • Validates that one of the given validators pass.

    Type Parameters

    • A
    • B
    • C

    Parameters

    Returns Validator<A | B | C, any>

  • Validates that one of the given validators pass.

    Type Parameters

    • A
    • B
    • C
    • D

    Parameters

    Returns Validator<
        | A
        | B
        | C
        | D, any>

  • Validates that one of the given validators pass.

    Type Parameters

    • A
    • B
    • C
    • D
    • E

    Parameters

    Returns Validator<
        | A
        | B
        | C
        | D
        | E, any>

  • Parameters

    Returns Validator<any, any>