@up-group-ui/react-controls
Version:
Up shared react controls
39 lines • 1.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var ValidationManager = (function () {
function ValidationManager() {
this.errorControl = [];
}
ValidationManager.prototype.addControl = function (control) {
this.errorControl.push(control);
};
ValidationManager.prototype.isValidValue = function (value) {
var newValue = value;
var firstError = null;
this.errorControl.forEach(function (handler) {
if (firstError == null) {
var result = handler.isValidValue(value);
if (result.hasError) {
firstError = result;
}
else if (result.correctValue !== undefined) {
newValue = result.correctValue;
}
}
});
if (firstError != null) {
return firstError;
}
if (this.errorControl.length) {
return {
hasError: false,
errorMessage: null,
correctValue: newValue,
};
}
return null;
};
return ValidationManager;
}());
exports.default = ValidationManager;
//# sourceMappingURL=ValidationManager.js.map