UNPKG

trade360-nodejs-sdk

Version:
37 lines 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MqConnectionSettingsValidator = void 0; const errors_1 = require("../../entities/errors"); const mq_settings_schema_1 = require("./mq-settings.schema"); /** * Class for validate that the configure mq setting * is valid. Use MQSettingsSchema to parse and validate * data. */ class MqConnectionSettingsValidator { /** * Validate the mqSettings object using the * MQSettingsSchema. * @param mqSettings the mqSettings object to validate * @returns the validated mqSettings object as * MQSettingsOptions type if the object is valid and * the validation passes successfully without errors or * exceptions thrown by the schema parser and validator * @throws ValidationError if the mqSettings object is * invalid and the validation fails with errors or * exceptions thrown by the schema parser and validator */ static validate(mqSettings) { const { success, data, error } = mq_settings_schema_1.MQSettingsSchema.safeParse(mqSettings); if (success) { return data; } else { throw new errors_1.ValidationError('Configuration settings', { context: JSON.parse(JSON.stringify(error.errors)), }); } } } exports.MqConnectionSettingsValidator = MqConnectionSettingsValidator; //# sourceMappingURL=mq-settings.validator.js.map