middleware(broker) {
		const self = this;
		const paramName = this.opts.paramName;

		const processCheckResponse = function (ctx, handler, res, additionalInfo) {
			if (res === true) return handler(ctx);
			else {
				res = res.map(data => Object.assign(data, additionalInfo));
				return broker.Promise.reject(
					new ValidationError("Parameters validation error!", null, res)
				);
			}
		};

		return {
			name: "Validator",
			localAction: function validatorMiddleware(handler, action) {
				// Wrap a param validator
				if (action[paramName] && typeof action[paramName] === "object") {
					const check = self.compile(action[paramName]);
					return function validateContextParams(ctx) {
						const res = check(ctx.params != null ? ctx.params : {}, { meta: ctx });
						if (check.async)
							return res.then(res =>
								processCheckResponse(ctx, handler, res, {
									nodeID: ctx.nodeID,
									action: ctx.action.name
								})
							);
						else
							return processCheckResponse(ctx, handler, res, {
								nodeID: ctx.nodeID,
								action: ctx.action.name
							});
					};
				}
				return handler;
			},

			localEvent: function validatorMiddleware(handler, event) {
				// Wrap a param validator
				if (event[paramName] && typeof event[paramName] === "object") {
					const check = self.compile(event[paramName]);
					return function validateContextParams(ctx) {
						const res = check(ctx.params != null ? ctx.params : {}, { meta: ctx });

						if (check.async)
							return res.then(res =>
								processCheckResponse(ctx, handler, res, {
									nodeID: ctx.nodeID,
									event: ctx.event.name
								})
							);
						else
							return processCheckResponse(ctx, handler, res, {
								nodeID: ctx.nodeID,
								event: ctx.event.name
							});
					};
				}
				return handler;
			}
		};
	}
Register validator as a middleware

@memberof BaseValidator