0.3.0 • Published 6 years ago

svv v0.3.0

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

Simple Value Validator

A small module the validate values easily (opinionated).

Install:

yarn add svv
// or
npm install svv

Usage example:

import { Runner, Item } from 'svv';

const validator = new Runner();

validator.all([
    new Item('content', property1).required(),
    new Item('category', property2).requiredIf(property1 === 'something')
], { /* options */ })
.then((result) => {
    if (result.valid) {
       // valid
    } else {
       // invalid
       //
       // checking if the error is specific to a field:
       // result.errors.has('content') => boolean // content has errors
       //
       // checking the first error message for a field
       // result.errors.first('content') => 'The content field is required'
    }
});

Homepage

API DOCS v0.2.3

0.3.0

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.0

6 years ago

0.0.1

7 years ago