|
|
@ -1,6 +1,6 @@ |
|
|
|
import * as is from '@sindresorhus/is'; |
|
|
|
import { ArgumentError } from './lib/argument-error'; |
|
|
|
import { Predicate } from './lib/predicates/predicate'; |
|
|
|
import { Predicate, validatorSymbol } from './lib/predicates/predicate'; |
|
|
|
import { StringPredicate } from './lib/predicates/string'; |
|
|
|
|
|
|
|
export interface Ow { |
|
|
@ -12,7 +12,7 @@ export interface Ow { |
|
|
|
} |
|
|
|
|
|
|
|
export const ow: Ow = (value: any, predicate: Predicate) => { |
|
|
|
for (const { validator, message } of predicate.validators) { |
|
|
|
for (const { validator, message } of predicate[validatorSymbol]) { |
|
|
|
if (!validator(value)) { |
|
|
|
// TODO: Modify the stack output to show the original `ow()` call instead of this `throw` statement
|
|
|
|
throw new ArgumentError(message(value), ow); |
|
|
|