Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/typeguardkit/mod.ts>ObjectAsserter

A TypeScript module to help construct type assertion functions and type guards.
Latest
class ObjectAsserter
implements Asserter<AssertedObject<PropertyAsserters>>
Re-export
import { ObjectAsserter } from "https://deno.land/x/typeguardkit@0.33.0/mod.ts";

An ObjectAsserter is an Asserter for the object type defined by its propertyAsserters.

The provided propertyAsserters are made accessible as a property of the created ObjectAsserter.

Example:

import { _string, Asserted, ObjectAsserter, option } from "typeguardkit";

export const _User = new ObjectAsserter("User", {
  name: _string,
  emailAddress: option(_string),
});

export type User = Asserted<typeof _User>;

Constructors

new
ObjectAsserter(typeName: string, propertyAsserters: PropertyAsserters)

Type Parameters

PropertyAsserters extends Record<string, Asserter<unknown>>

Properties

readonly
typeName: string

Methods

assert(value: unknown, valueName?: string): AssertedObject<PropertyAsserters>