import { OptionAsserter } from "https://deno.land/x/typeguardkit@0.33.0/mod.ts";
An OptionAsserter
is an Asserter
for the union of the Type
of its
definedTypeAsserter
with undefined
, intended to be used with
ObjectAsserter
to assert optional properties.
The provided definedTypeAsserter
is made accessible as a property of the
created OptionAsserter
.
The option
function can be used to create an OptionAsserter
without
specifying a typeName
.
Example:
import { _string, OptionAsserter } from "typeguardkit";
export const _OptionalString = new OptionAsserter("OptionalString", _string);
Constructors
new
OptionAsserter(typeName: string, definedTypeAsserter: DefinedTypeAsserter)Type Parameters
DefinedTypeAsserter extends Asserter<unknown>
Methods
assert(value: unknown, valueName?: string): Asserted<DefinedTypeAsserter> | undefined