@mdf.js/service-registry
Version:
MMS - API - Service Registry
33 lines • 1.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Validator = void 0;
/**
* Copyright 2024 Mytra Control S.L. All rights reserved.
*
* Use of this source code is governed by an MIT-style license that can be found in the LICENSE file
* or at https://opensource.org/licenses/MIT.
*/
const crash_1 = require("@mdf.js/crash");
const utils_1 = require("@mdf.js/utils");
/** Validator class */
class Validator {
/**
* Return all the actual metrics of this artifact
* @param request - HTTP request express object
* @param response - HTTP response express object
* @param next - Next express middleware function
*/
metrics(request, response, next) {
if (request.query['json'] && typeof (0, utils_1.coerce)(request.query['json']) !== 'boolean') {
const validationError = new crash_1.Multi(`Errors during the schema validation process`, request.uuid, { name: 'ValidationError' });
const jsonFormatError = new crash_1.Crash(`Should be a boolean - Path: [/json] - Value: [${JSON.stringify(request.query['json'])}]`, request.uuid, { name: 'ValidationError' });
validationError.push(jsonFormatError);
next(validationError);
}
else {
next();
}
}
}
exports.Validator = Validator;
//# sourceMappingURL=metrics.validator.js.map