silfverorg / duns.js

Javascript schema validator
5 stars 2 forks source link

Duns.assert should be able to take a message #49

Open br0r opened 9 years ago

br0r commented 9 years ago
Duns.assert('ninja', Duns.number(), 'Not a valid number');
// Error{name: 'Duns Error', message: 'Not a valid number'}

Otherwise you would have to do this in tests:

try {
  Duns.assert('ninja', Duns.number());
} catch (err) {
  throw new Error('Invalid number');
}

Kind of defeats the purpose with .assert

silfverstrom commented 9 years ago

+1