Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

inspector-with-exceptions

doox9113MIT1.0.3

Data type validator with custom exceptions

validator, inspector, exceptions, custom extensions, types

readme

Install

$ npm install inspector-with-exceptions

Usage

import MyCustomException from './MyCustomException';

const Inspector = require('inspector-with-exceptions');

Example

import MyCustomException from './MyCustomException';

const Inspector = require('inspector-with-exceptions');

const value = null;

/**
 * Some logic
 */

try {
  Inspector.isNumber(value, 'Must be a number', MyCustomException);
} catch (e) {
  if (e instanceof MyCustomException) {
    console.log('MyCustomException');
  }
}