⚠️ This project is still in early alpha. Please report bugs on GitHub.

Introduction

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

ℹ️

ValidaThor is not yet published, so the following command will not work.

npm i validathor

Example

Here's a basic example usecase

  import {
    // Schemas
    object, string, number, boolean, date,
    // Modifiers
    min, max, minLength, email,
  } from 'validathor';
 
  // Define the shape of your schema
  // Make use of modifiers in places where it makes sense
  const exampleSchema = object({
    name: string([minLength(2)]),
    age: number([min(13), max(100)]),
    email: string([email()]),
    avatar: object({
      path: string(),
      size: number([min(0)]),
    }),
    acceptedTerms: boolean(),
    createdAt: date([
      minDate(new Date('2021/01/01')),
      maxDate(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).