Checks if one of the assertions passes.

If none of them passes it throws an error.

If you have two or three assertions consider using or2 or or3 respectively.

const trueish = or([literal(1), literal(true), literal("true"), literal("yes")]);

trueish("yassss"); // Error: literal
trueish(1); // passes
trueish(true); // passes
trueish("true"); // passes
trueish("yes"); // passes
  • Type Parameters

    • const $Values extends unknown[]

    Parameters

    • assertions: {
          [$Key in string | number | symbol]: Assertion<$Values[$Key<$Key>]>
      }

      Array of assertions to be checked

    Returns Assertion<$Values[number]>