The value schema validates that the input is exactly any given literal value. This schema allows you to verify the values undefined and null, as well as any other literal primitive value.
value
undefined
null
import { value } from "typerun/schema";import { is } from "typerun";if (is(value(true))(true)) { console.log("true is true");}if (!is(value(true))(false)) { console.log("false is not true");}if (!is(value(undefined))(null)) { console.log("null is not undefined");} Copy
import { value } from "typerun/schema";import { is } from "typerun";if (is(value(true))(true)) { console.log("true is true");}if (!is(value(true))(false)) { console.log("false is not true");}if (!is(value(undefined))(null)) { console.log("null is not undefined");}
The literal value to validate.
The
value
schema validates that the input is exactly any given literal value. This schema allows you to verify the valuesundefined
andnull
, as well as any other literal primitive value.Example