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'; |
'use strict'; |
||||
const ow = require('./dist'); |
const ow = require('./dist'); |
||||
|
|
||||
const fn = (input, options) => { |
const logError = fn => { |
||||
ow(input, ow.string.minLength(10)); |
try { |
||||
|
fn(); |
||||
|
} catch (err) { |
||||
|
console.log(err.message); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
// For objects, just an idea for now:
|
const fn = input => { |
||||
// ow.many(options, {
|
ow(input, ow.string.minLength(10)); |
||||
// tasks: ow.number.range(0, 10),
|
|
||||
// extras: ow.arrayOf(ow.number)
|
|
||||
// });
|
|
||||
}; |
}; |
||||
|
|
||||
//fn(10);
|
logError(() => { |
||||
//=> ArgumentError: Expected argument to be of type `string` but received type `number`
|
fn(10); |
||||
|
}); |
||||
|
|
||||
|
logError(() => { |
||||
fn('foo'); |
fn('foo'); |
||||
//=> ArgumentError: Expected string length to be minimum 10
|
}); |
||||
|
Loading…
Reference in new issue