Skip to main content
Module

x/abstruct/mod.ts>TypeValidator

Abstract structure for JavaScript data validation
Go to Latest
class TypeValidator
extends ScalarValidator<unknown, TypeMap[T]>
import { TypeValidator } from "https://deno.land/x/abstruct@1.0.0-beta.7/mod.ts";

Validator for JavaScript data type. It executes typeof like operator. The difference with typeof operator is that "object" does not match null.

Examples

Example 1

import { TypeValidator } from "https://deno.land/x/abstruct@$VERSION/validators/operators/typeof.ts";
const iterable =new TypeValidator("string").validate(0);

Constructors

new
TypeValidator(of: T)

Methods

is(input: unknown): input is TypeMap[T]
toString(): string