UNPKG

854 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.validateEach = exports.InvalidDecoratorItemException = void 0;
4class 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}
14exports.InvalidDecoratorItemException = InvalidDecoratorItemException;
15function 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}
25exports.validateEach = validateEach;