transbank-sdk
Version:
Transbank SDK for Node.js
29 lines (28 loc) • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var ValidationUtil = /** @class */ (function () {
function ValidationUtil() {
}
ValidationUtil.hasText = function (value, valueName) {
if (value == null || value == undefined || value.trim() == "")
throw new Error("'" + valueName + "'" + " can't be null or white space");
};
ValidationUtil.hasTextWithMaxLength = function (value, length, valueName) {
ValidationUtil.hasText(value, valueName);
if (value.length > length)
throw new Error("'" + valueName + "'" + " is too long, the maximum length is " + length);
};
ValidationUtil.hasTextTrimWithMaxLength = function (value, length, valueName) {
ValidationUtil.hasText(value, valueName);
if (value.length > value.trim().length)
throw new Error("'" + valueName + "'" + " has spaces at the beginning or the end");
if (value.length > length)
throw new Error("'" + valueName + "'" + " is too long, the maximum length is " + length);
};
ValidationUtil.hasElements = function (value, valueName) {
if (value == null || value.length == 0)
throw new Error("list '" + valueName + "'" + " can't be null or empty");
};
return ValidationUtil;
}());
exports.default = ValidationUtil;