1.1.0 • Published 8 years ago
tcomb-pretty-match v1.1.0
tcomb-pretty-match
Colorful diff for tcomb-validation
Install
$ npm install tcomb-pretty-match --save-dev
Examples
ava
import test from 'ava';
import t from 'tcomb-validation';
import match from 'tcomb-pretty-match';
const User = t.struct({ username: t.String });
test('user valid', t => {
match({ username: 'admin' }, User); // nothing
match({ username: 1 }, User); // screenshot below
});
ava with helper
import test from 'ava';
import t from 'tcomb-validation';
import { match, throws } from 'tcomb-pretty-match/ava';
const User = t.struct({ username: t.String });
test('user valid', t => {
match(t, { username: 'admin' }, User);
throws(t, { username: 1 }, User);
throws(t, { id: 1 }, User);
throws(t, { id: 1, username: 'admin' }, User, { strict: true });
});
License
MIT © ewnd9