Validators

Discover every validators included with vuito to speed up your development.

๐Ÿ’ก Remember, vuito is tree-shakeable. So each validators can be loaded independantly.

How to import

import { regex, required } from 'vuito';
// OR
const { regex, required } = require('vuito');
// OR
const regex = require('vuito/validators/regex.cjs');

required

Check if the input value is truthy.

Usage:

{ test: required, message: "Can't be empty." }

minLength

Check if string/array length is at least n long.

Usage:

{ test: minLength(5), message: 'Should be at least 5 long.' }

maxLength

Check if string/array length is at most n long.

Usage:

{ test: maxLength(5), message: 'Should be at most 5 long.' }

minValue

Check if string/number value is >= n.

Usage:

{ test: minValue(5), message: 'Should be less or equal to 5.' }

maxValue

Check if string/number value is <= n.

Usage:

{ test: maxValue(5), message: 'Should be more or equal to 5.' }

minValue

Check if string/number value is >= n.

Usage:

{ test: minValue(5), message: 'Should be less or equal to 5.' }

onlyText

Check if string input contains only alphanumeric chars or white spaces.

Handle diactirics removal.

Usage:

{ test: onlyText, message: 'Should be more or equal to 5.' }

regex

Check if string input match the given regex.

Usage:

{ test: regex(/^ac?b$/i), message: 'Should be "ab" or "acb".' }