1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.CustomCondition = void 0;
|
4 | const base_1 = require("../base");
|
5 | class CustomCondition {
|
6 | constructor(condition) {
|
7 | this.condition = condition;
|
8 | }
|
9 | async run(_context, value, meta) {
|
10 | try {
|
11 | const result = this.condition(value, meta);
|
12 | await result;
|
13 |
|
14 | if (!result) {
|
15 |
|
16 | throw new Error();
|
17 | }
|
18 | }
|
19 | catch (e) {
|
20 | throw new base_1.ValidationHalt();
|
21 | }
|
22 | }
|
23 | }
|
24 | exports.CustomCondition = CustomCondition;
|