Skip to content
/ scond Public

A small library that performs multi validation execution

License

Notifications You must be signed in to change notification settings

dronbas/scond

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scond

=========

CircleCI codecov License: MIT bitHound Overall Score bitHound Dependencies contributions welcome code style: prettier

A small library that performs multi validation execution

Installation

npm i -S scond

or

yarn add scond

Usage

Simple case

const Scond = require('scond');

const scond = new Scond();

const check1 = {
  id: 'test_cond_1',
  check: values => {
    return values.user.access_level > 10
  }
};

const check2 = {
  id: 'test_cond_2',
  check: values => {
    return typeof values.user === 'object'
  }
};

const check3 = {
  id: 'test_cond_3',
  check: values => {
    return values.user.access_level > 100
  }
};

scond.addMulti([check1, check2]);

const values = {user: {
  access_level: 42
}};

scond.exec([{id: 'test_cond_2'}, {id: 'test_cond_1'}], values); //true

scond.add(check3);

scond.exec([{id: 'test_cond_2'}, {id: 'test_cond_1'}, {id: 'test_cond_3'}], values); //false

Tests

npm test or yarn test

Contributing

If you want to join this case by help maintaining something, please don't hesitate to contact.

I'm happy to receive bug reports, fixes, documentation enhancements, and any other improvements.

And since I'm not a native English speaker, if you find any grammar mistakes in the documentation, please also let me know. :)