Shreyas arya

Generation

generate functionMon, 23 Jan 2023

We need to create validators for each status. The validator will check if transition from current state is allowed or not.

Script var validStatus = { 'new': ['pending'], 'pending': ['approved', 'rejected'], 'approved': [], 'rejected': [] } var isValidStatus = function (currentStatus, newStatus) { return validStatus[currentStatus].indexOf(newStatus) >= 0; }; isValidStatus('new', 'pending');

Want to kickstart your project?Use the new AI Studio to create your code