import { or } from "https://deno.land/x/abstruct@1.0.0/mod.ts";
Factory for validator composer like Logical OR.
Examples
Example 1
Example 1
import {
or,
type Validator,
} from "https://deno.land/x/abstruct@$VERSION/mod.ts";
import { assertType, type Has } from "https://deno.land/std/testing/types.ts";
declare const v1: Validator;
declare const v2: Validator;
declare const v3: Validator;
const validator = or(v1, v2, v3);
If the validators are not type-compatible with each other, generics must be specified.
Example 2
Example 2
import {
or,
type Validator,
} from "https://deno.land/x/abstruct@$VERSION/mod.ts";
import { assertType, type Has } from "https://deno.land/std/testing/types.ts";
declare const v1: Validator<unknown, string>;
declare const v2: Validator<unknown, number>;
const validator = or<unknown, string | number>(v1, v2);
assertType<Has<typeof validator, Validator<unknown, string | number>>>(true);
For more information, see Specifying Type Arguments.