@nestjs/common
Version:
Nest - modern, fast, powerful node.js web framework (@common)
21 lines (20 loc) • 798 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const runtime_exception_1 = require("@nestjs/core/errors/exceptions/runtime.exception");
class InvalidDecoratorItemException extends runtime_exception_1.RuntimeException {
constructor(decorator, item, context) {
super(`Invalid ${item} passed to ${decorator}() decorator (${context}).`);
}
}
exports.InvalidDecoratorItemException = InvalidDecoratorItemException;
function validateEach(context, arr, predicate, decorator, item) {
if (!context || !context.name) {
return true;
}
const errors = arr.some(str => !predicate(str));
if (errors) {
throw new InvalidDecoratorItemException(decorator, item, context.name);
}
return true;
}
exports.validateEach = validateEach;