Shreyas arya

Generation

generate functionMon, 23 Jan 2023

Validators are implemented for each workflow execution status Validators are applied in production code

Script function Status(status) { this._status = status; this._validators = []; } Status.prototype.addValidator = function(validator) { this._validators.push(validator); } Status.prototype._applyValidators = function() { for (var i = 0; i < this._validators.length; i++) { this._validators[i](this._status); } } var status = new Status('new'); //add validator status.addValidator(function(status) { if (status === 'new') { console.log('status is new'); } }); //add another validator status.addValidator(function(status) { if (status === 'new') { throw new Error('status is new'); } }); //execute validators status._applyValidators();

Questions about programming?Chat with your personal AI assistant