Match shallow objects
$ npm install --save matchy
var Match = require('matchy')
var match = Match([
{type: 'FooType'},
{name: /Bar$/},
{message: (value) => value && value.split('').reverse().join('') === 'raBooF'}
])
match({type: 'FooType'})
//=> true
match({name: 'FooBar'})
//=> true
match({name: 'FooBaz'})
//=> false
Required
Type: object
A shallow object where the keys are error data keys and the values are:
- Strings or numbers (checked for strict equality)
- Regular expressions
- Functions (called with the error value for that key)
MIT © Ben Drucker