vality
TypeScript icon, indicating that this package has built-in type declarations

6.3.4 • Public • Published

Vality

A TypeScript schema descriptor library with zero dependencies.

License Version Build Status Coverage Status

Snyk Dependencies Bundlephobia

See https://jeengbe.github.io/vality for more information.

Vality is the heart of this repository. It is a declarative schema description library with the most intuitive syntax and allows for validation and transformation of data. Then extract the types from your schema for 100% type safety. And all with 0 runtime dependencies.

Find all of this and much more on https://jeengbe.github.io/vality/vality.

import { v, Parse } from "vality";

const Person = {
  name: v.string,
  age: v.number({ min: 6 }),
  email: v.email,
  referral: ["friends", "ad", "media", null],
  languages: [["de", "en", "fr", "se"]],
} as const;

type Person = Parse<typeof Person>;
/* {
  name: string;
  age: number;
  email: Email;
  referral: "friends" | "ad" | "media" | null;
  languages: ("de" | "en" | "fr" | "se")[];
} */

Now that I have your attention, head over to https://jeengbe.github.io/vality/vality to find out what's going on here. You won't regret it ;)

Or head to GitHub to find more useful packages (such as Vality ESLint Plugin).

And before you complain about errors, make sure your tsconfig supports at least the following:

{
  "compilerOptions": {
    "strictNullChecks": true,
    "lib": ["ES2015"]
  }
}

Package Sidebar

Install

npm i vality

Weekly Downloads

303

Version

6.3.4

License

MIT

Unpacked Size

200 kB

Total Files

117

Last publish

Collaborators

  • jeengbe