Skip to content

Commit 70f5d58

Browse files
committed
feat: added helper file for toast and email validation
1 parent ac09dd1 commit 70f5d58

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

helpers/index.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { toast } from "react-toastify";
2+
3+
const helpers = {
4+
/***** Hardcoded RegEx for Email validations *****/
5+
validEmail: (email) => {
6+
let valid =
7+
/^(([^<>()[\]\\.,;:\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,}))$/;
8+
9+
let specials = /[*|\":<>[\]{}`\\()';&$]/;
10+
11+
return valid.test(email) && !specials.test(email);
12+
},
13+
14+
/***** Toast for Base Error Messages by using React Toastify library *****/
15+
alertToastHandling: (message, position = "top-right") => {
16+
toast(message, {
17+
position: "top-right" || position,
18+
autoClose: 5000,
19+
hideProgressBar: false,
20+
closeOnClick: true,
21+
pauseOnHover: true,
22+
draggable: true,
23+
progress: undefined,
24+
});
25+
},
26+
};
27+
28+
export { helpers };

0 commit comments

Comments
 (0)