The set schema validates that the input is a set of elements that match the schema. It fails for anything that is not a set, or for any element of the set that does not match the schema.
set
import { set, number } from "typerun/schema";import { is } from "typerun";const isSet = is(set(number))(new Set([1, 2, 3]));console.log(isSet); // trueconst isNotSet = is(set(number))([1, 2, 3]);console.log(isNotSet); // falseconst isNotCorrectSet = is(set(number))(new Set([1, 2, "3"]));console.log(isNotCorrectSet); // false Copy
import { set, number } from "typerun/schema";import { is } from "typerun";const isSet = is(set(number))(new Set([1, 2, 3]));console.log(isSet); // trueconst isNotSet = is(set(number))([1, 2, 3]);console.log(isNotSet); // falseconst isNotCorrectSet = is(set(number))(new Set([1, 2, "3"]));console.log(isNotCorrectSet); // false
The schema to validate the elements of the set.
The
set
schema validates that the input is a set of elements that match the schema. It fails for anything that is not a set, or for any element of the set that does not match the schema.Example