Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/valibot/src/utils/isOfType/index.ts>isOfType

The modular and type safe schema library for validating structural data 🤖
Extremely Popular
Latest
function isOfType
import { isOfType } from "https://deno.land/x/valibot@1.0.0-beta.0-to-json-schema/src/utils/isOfType/index.ts";

A generic type guard to check the type of an object.

Type Parameters

TType extends TObject["type"]
TObject extends { type: string; }

Parameters

type: TType

The type to check for.

object: TObject

The object to check.

Returns

object is Extract<TObject, { type: TType; }>

Whether it matches.