ValidaThor ⚡️
What exactly is it? It's a super simple, validation library!
Define the shape of your data using our schemas and modifiers, and match it against your data for easy validation.
Getting started
npm i @nordic-ui/validathor
Example
Here's a basic example usecase
import * as v from '@nordic-ui/validathor';
// Define the shape of your schema
// Make use of modifiers in places where it makes sense
const exampleSchema = v.object({
name: v.string([v.min(2)]),
age: v.number([v.min(13), v.max(100)]),
email: v.string([v.email()]),
avatar: v.object({
path: v.string(),
size: v.number([v.min(0)]),
}),
acceptedTerms: v.boolean(),
createdAt: v.date([
v.min(new Date('2021/01/01')),
v.max(new Date()),
]),
});
Credits
- Built by Kevin Østerkilde (opens in a new tab)
- Inspired by the likes of Zod (opens in a new tab) and Valibot (opens in a new tab).