@whi/skeptic

0.1.5 • Public • Published

Skeptic

A quality control validation library built on top of @whi/serious-error-types. It enables developers to clearly state input/output assumptions in their code.

Overview

These validation methods cover more complex scenarios and throw specific error types where assert statements would only throw AssertionError.

Usage

const { SeriousErrors,
        FunctionIO,
        DatabaseIO } = require('@whi/skeptic');

function user ( name, age ) {
    FunctionIO.validateArguments(arguments, [
        FunctionIO.requiredArgumentType("string", "User's Name"),
        FunctionIO.optionalArgumentType("number", "User's Age"),
    ]);
}

user();
// throws MissingArgumentError

user( 22 );
// throws InvalidArgumentError

user( "Dave" );
// will not throw

user( "Dave", null );
// throws InvalidArgumentError

user( "Dave", 22 );
// will not throw

Readme

Keywords

none

Package Sidebar

Install

npm i @whi/skeptic

Weekly Downloads

3

Version

0.1.5

License

ISC

Unpacked Size

21.4 kB

Total Files

4

Last publish

Collaborators

  • brisebom