vality
v6.3.4
Published
A TypeScript schema descriptor library with zero dependencies.
Downloads
966
Maintainers
Readme
A TypeScript schema descriptor library with zero dependencies.
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"]
}
}