Skip to content

Commit

Permalink
feat: added helper file for toast and email validation
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushsoni1010 committed Feb 18, 2023
1 parent ac09dd1 commit 70f5d58
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions helpers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { toast } from "react-toastify";

const helpers = {
/***** Hardcoded RegEx for Email validations *****/
validEmail: (email) => {
let valid =
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

let specials = /[*|\":<>[\]{}`\\()';&$]/;

return valid.test(email) && !specials.test(email);
},

/***** Toast for Base Error Messages by using React Toastify library *****/
alertToastHandling: (message, position = "top-right") => {
toast(message, {
position: "top-right" || position,
autoClose: 5000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined,
});
},
};

export { helpers };

0 comments on commit 70f5d58

Please sign in to comment.