Browse Source

Fix issue regarding resetting of the predicate chain

iss58
Sam Verschueren 7 years ago
parent
commit
54a73ca91e
  1. 25
      source/ow.ts

25
source/ow.ts

@ -10,16 +10,19 @@ export interface Ow {
string: StringPredicate;
}
export const ow: Ow = Object.assign(
(value: any, predicate: Predicate) => {
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);
}
const main = (value: any, predicate: Predicate) => {
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), main);
}
},
{
string: new StringPredicate()
}
);
};
Object.defineProperties(main, {
string: {
get: () => new StringPredicate()
}
});
export const ow = main as Ow;

Loading…
Cancel
Save