0.1.5 • Published 3 years ago

@whi/skeptic v0.1.5

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

npm.io

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.

npm.io npm.io npm.io

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