mirror of https://github.com/lukechilds/ow.git
Sindre Sorhus
7 years ago
3 changed files with 26 additions and 14 deletions
@ -1,18 +1,22 @@ |
|||
'use strict'; |
|||
const ow = require('./dist'); |
|||
|
|||
const fn = (input, options) => { |
|||
ow(input, ow.string.minLength(10)); |
|||
const logError = fn => { |
|||
try { |
|||
fn(); |
|||
} catch (err) { |
|||
console.log(err.message); |
|||
} |
|||
}; |
|||
|
|||
// For objects, just an idea for now:
|
|||
// ow.many(options, {
|
|||
// tasks: ow.number.range(0, 10),
|
|||
// extras: ow.arrayOf(ow.number)
|
|||
// });
|
|||
const fn = input => { |
|||
ow(input, ow.string.minLength(10)); |
|||
}; |
|||
|
|||
//fn(10);
|
|||
//=> ArgumentError: Expected argument to be of type `string` but received type `number`
|
|||
logError(() => { |
|||
fn(10); |
|||
}); |
|||
|
|||
fn('foo'); |
|||
//=> ArgumentError: Expected string length to be minimum 10
|
|||
logError(() => { |
|||
fn('foo'); |
|||
}); |
|||
|
Loading…
Reference in new issue