Skip to content

Repository files navigation

@nrfcloud/validate-with-typebox

https://www.npmjs.com/package/@nrfcloud/validate-with-typebox

Helper function to validate data with TypeBox schemas.

Install with NPM

npm i (--save-prod|--save-dev) @nrfcloud/validate-with-typebox

Usage

import { fetchWithDebug } from "@nrfcloud/validate-with-typebox";
import assert from "node:assert/strict";

const validateInput = validateWithTypeBox(
  Type.Object({
    email: Type.RegExp(/.+@.+/),
  }),
);

assert.equal(
  formatTypeBoxErrors(
    (
      validateInput({
        email: "f",
      }) as any
    ).errors,
  ),
  `/email: Expected string to match regular expression`,
);

TypeScript 6 and 7

This repo runs TypeScript 6 and 7 side by side, so that eslint works.

About

Helper function to validate data with TypeBox schemas.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages