1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.validateEach = exports.InvalidDecoratorItemException = void 0;
|
4 | class InvalidDecoratorItemException extends Error {
|
5 | constructor(decorator, item, context) {
|
6 | const message = `Invalid ${item} passed to ${decorator}() decorator (${context}).`;
|
7 | super(message);
|
8 | this.msg = message;
|
9 | }
|
10 | what() {
|
11 | return this.msg;
|
12 | }
|
13 | }
|
14 | exports.InvalidDecoratorItemException = InvalidDecoratorItemException;
|
15 | function validateEach(context, arr, predicate, decorator, item) {
|
16 | if (!context || !context.name) {
|
17 | return true;
|
18 | }
|
19 | const errors = arr.some(str => !predicate(str));
|
20 | if (errors) {
|
21 | throw new InvalidDecoratorItemException(decorator, item, context.name);
|
22 | }
|
23 | return true;
|
24 | }
|
25 | exports.validateEach = validateEach;
|