Skip to main content
Module

x/abstruct/mod.ts>defineValidator

Abstract structure for JavaScript data validation
Latest
function defineValidator
import { defineValidator } from "https://deno.land/x/abstruct@1.0.0/mod.ts";

Create Validator from Validator.validate.

Examples

const StringValidator = defineValidator<unknown, string>(function* (input) { const typeOf = typeof input; if (typeOf !== "string") { yield { message: should be string, actual ${typeOf}, instancePath: [] }; } });

Type Parameters

In
optional
RIn extends In = In

Parameters

validate: (input: In) => Iterable<ValidationFailure>