@aurigma/design-atoms-model
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
35 lines • 2.07 kB
JavaScript
var CmykComponentValidator = /** @class */ (function () {
function CmykComponentValidator(_sourceString, _regexArray, _maxValue) {
this._sourceString = _sourceString;
this._regexArray = _regexArray;
this._maxValue = _maxValue;
}
CmykComponentValidator.prototype.validate = function () {
var format = function (name, value) {
return "ComponentName - " + name + ", Value - " + value + "; ";
};
var invalidComponentsMessage = "";
if (!this._validate(this._regexArray[1]))
invalidComponentsMessage = invalidComponentsMessage.concat(format("C", this._regexArray[1]));
if (!this._validate(this._regexArray[2]))
invalidComponentsMessage = invalidComponentsMessage.concat(format("M", this._regexArray[2]));
if (!this._validate(this._regexArray[3]))
invalidComponentsMessage = invalidComponentsMessage.concat(format("Y", this._regexArray[3]));
if (!this._validate(this._regexArray[4]))
invalidComponentsMessage = invalidComponentsMessage.concat(format("K", this._regexArray[4]));
if (this._regexArray[5] != undefined && !this._validate(this._regexArray[5]))
invalidComponentsMessage = invalidComponentsMessage.concat(format("A", this._regexArray[5]));
if (invalidComponentsMessage.length > 0) {
var lastSemicolonIndex = invalidComponentsMessage.length - 2;
invalidComponentsMessage = invalidComponentsMessage.substring(0, lastSemicolonIndex);
console.warn("Invalid value of CMYK components. SourceString: " + this._sourceString + "; InvalidComponents: " + invalidComponentsMessage + ".");
}
};
CmykComponentValidator.prototype._validate = function (value) {
var normalizedValue = parseFloat(value);
return normalizedValue >= 0 && normalizedValue <= this._maxValue;
};
return CmykComponentValidator;
}());
export { CmykComponentValidator };
//# sourceMappingURL=CmykComponentValidator.js.map