Skip to content

Commit

Permalink
added user choice to join or create group
Browse files Browse the repository at this point in the history
  • Loading branch information
abhiraj-ku committed Aug 30, 2024
1 parent 4b7c325 commit d373510
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions helpers/validateUserChoice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports.validateUsersChoice = (choice, options) => {
if (!choice) {
return {
isValid: false,
message: "User Choice is mandatory",
};
}

if (!options.includes(choice)) {
return {
isValid: false,
message: `Invalid choice, Please choose one of the options: ${options.join(
", "
)}`,
};
}

return { isValid: true };
};

0 comments on commit d373510

Please sign in to comment.