Getting Started
Installation
Install vuito
in your project
NPM
npm i vuito
Validate stuff
- 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.' },
],
});
- 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);
- 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!
Table of Contents