Introduction
Supports validating input data.
Capabilities and Frameworks
Capability | Module |
---|---|
Coding Standard |
eslint identifying and reporting on patterns found in ECMAScript/JavaScript code completely pluggable, babel-eslint support parsing ECMAScript for eslint |
Testing Framework |
lab nodejs test framework uses domains instead of uncaught exception and other global manipulation |
How to test
npm test
npm test:coverage
How to check lint
npm run lint
npm run lintFix
How to use
Install this module
npm install @askbills/util --save
Checking input value
const { Checking } = require('@askbills/util');
const inputValue = true;
if !(Checking.isBoolean(inputValue)) {
return;
}
doSomeThing();
ThrowError if condition doesn't match
const { Exception } = require('@askbills/util');
const inputValue = true;
try {
Exception.throwIfNotBoolean(inputValue, 'required Boolean');
doSomeThing();
} catch (e) {
console.log('required Boolean');
}