@v-n-b/voi

Some minor extensions to Joi in TypeScript

Usage no npm install needed!

<script type="module">
  import vNBVoi from 'https://cdn.skypack.dev/@v-n-b/voi';
</script>

README

Voi

Some minor extensions to Joi in TypeScript

Install

npm install @v-n-b/voi

Browser polyfills

Voi uses ES6 features and Map, so if you support older browsers you might need polyfills.

Usage

import { Voi } from '@v-n-b/voi';

enum Dnd {
    dungeons = 'dungeons',
    dragons = 'dragons',
}

Voi.voi().enum(Action).validate('dungeons');
// Validates

Voi.voi().enum(Status).validate('foo');
// Results in error with type 'voi.enum'

Voi.string().simpleEmail().validate('test@example.com');
// Validates

Voi.string().simpleEmail().validate('testexample.com');
// Results in error with type string.simpleEmail