We need to create validators for each status. The validator will check if transition from current state is allowed or not.
Script function getValidator(state) { return function(action) { return action === state; }; } const validator = getValidator('running'); validator('running'); // returns true