Skip to content

nRFCloud/validate-with-typebox

Repository files navigation

@nrfcloud/validate-with-typebox

https://jsr.io/@nrfcloud/validate-with-typebox

Helper function to validate data with TypeBox schemas.

Install with NPM

npx jsr add (--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`,
);

About

Helper function to validate data with TypeBox schemas.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors