Getting Started

Installation

Install vuito in your project

NPM
npm i vuito
Bun
bun i vuito
Yarn
yarn add vuito
PNPM
pnpm i vuito

Validate stuff

  1. Create your template, validations/auth.ts here.
validations/auth.ts
import { templateify, required, minLength, maxLength } from 'vuito';

export const signIn = templateify({
  username: [
    { test: required, message: 'Please enter a username.' },
    { test: minLength(3), message: 'Username is too short.' },
    { test: maxLength(20), message: 'Username is too big.' },
  ],
  password: [
    { test: required, message: 'Please enter a password.' },
    { test: minLength(12), message: 'Password is too short.' },
  ],
});
  1. Validate some data
main.ts
import { signIn } from './validations/auth';

const fields = {
  username: 'jeff',
  password: '2-pesos',
};

await signIn.check(fields)
  .then(() => console.log('Validated!'))
  .catch(console.error);
  1. Run the test
bun run main.ts
# Will return: "Password is too short."
โœจ Well done! I'm pretty sure you're already familiar with vuito now!