0.2.5 • Published 6 years ago

altheia v0.2.5

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Altheia

Build Status Coverage Status

A very simple async data validator, very fast and customizable, inspired by Joi .

await Alt.string().email().custom('not_in_db', (val) => searchDB(val))

Introduction

After searching for a long time a simple data validator that allow async validation, I decided to implement one. Heavily inspired from Joi, it aim at being very lightweight, simple to use and obvioulsy allow us to check anything from standard schema to very custom ones.

It aim to be used in models Validation (i.e: for API)

Install

$ npm install altheia

Example

const Alt = require('altheia');
// or: import Alt from 'altheia'

Alt.lang('string.min', (name, args) => `This ${name} is too short I think`});

const hasError = await Alt({
    login: Alt.string().min(3).not('admin').required(),
    email: Alt.string().email().custom('not_in_db', (val) => searchDB(val)),
    eyes: Alt.number().integer().positive().max(2),
    date: Alt.date().iso()
}).options({
    required: true,
    unknown: false
}).body({
    login: 'leela',
    email: 'captain@planetexpress.earth',
    eyes: 1,
    date: '2015-01-04T17:35:22Z'
}).validate();

console.log(hasError); // false

Documentation

You can find the documentation here

Contributing

Every contribution or request will be gladly accepted in this issues section.

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago