type-check-system

3.0.0 • Public • Published

Check

Build Status Coverage Status

A type checker for JavaScript inspired by Meteor's check.

npm install type-check-system --save

Usage

Check if value is a string.

const value = 'This is a string.';
check(value, String);

Check if value is a list of strings.

const value = ['a', 'b', 'c'];
check(value, [String]);

Check if value is a string, or null.

const value = 'string';
check(value, String, null);

Check if value is an object with key id with type string.

const value = {
    id: '0af390f0-abb6-4ef6-b9af-6287e6aab172'
};
check(value, {id: String});

Check if value is one of "foo", or "bar".

const value = 'bar';
check(value, 'foo', 'bar');

Please have a look at the tests to see more examples.

Limitations

This library does not expose any Match-like functions, like Meteor's check library. Instead, this library only uses a check based on patterns to keep it's api simple. If you want Match features, have a look at meteor-check instead.

Tests

To execute the tests, run the following commands:

npm run build
npm run test

Readme

Keywords

none

Package Sidebar

Install

npm i type-check-system

Weekly Downloads

46

Version

3.0.0

License

MIT

Last publish

Collaborators

  • martijndeh