trade360-nodejs-sdk
Version:
LSports Trade360 SDK for Node.js
28 lines • 1.58 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetTranslationsRequestValidator = void 0;
const lodash_1 = require("lodash");
const _entities_1 = require("../../../entities/core-entities/index.js");
/**
* GetTranslationsRequestValidator class
* (used for validation) - validates the request
* body of the translations collection endpoint.
*/
class GetTranslationsRequestValidator {
static validate(request) {
// Ensure Languages is filled
if ((0, lodash_1.isNil)(request.languages) || (0, lodash_1.isEmpty)(request.languages)) {
throw new _entities_1.TranslationsValidationError('Languages must be filled.');
}
// Ensure at least one of the other fields is filled
if (((0, lodash_1.isNil)(request.sportIds) || (0, lodash_1.isEmpty)(request.sportIds)) &&
((0, lodash_1.isNil)(request.locationIds) || (0, lodash_1.isEmpty)(request.locationIds)) &&
((0, lodash_1.isNil)(request.leagueIds) || (0, lodash_1.isEmpty)(request.leagueIds)) &&
((0, lodash_1.isNil)(request.marketIds) || (0, lodash_1.isEmpty)(request.marketIds)) &&
((0, lodash_1.isNil)(request.participantIds) || (0, lodash_1.isEmpty)(request.participantIds))) {
throw new _entities_1.TranslationsValidationError('At least one of SportIds, LocationIds, LeagueIds, MarketIds, or ParticipantIds must be filled.');
}
}
}
exports.GetTranslationsRequestValidator = GetTranslationsRequestValidator;
//# sourceMappingURL=translations-request-validator.js.map