-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathValidation.js
53 lines (46 loc) · 1.29 KB
/
Validation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class Validation {
onChangePlainTextCharacter(txtInput) {
const regex = /[`~,.<>;':"\/\[\]\|{}()=_+\-!@#$%^&*]/;
if (!regex.test(txtInput)) {
return true;
}
return false;
}
onChangeNumberValidate(txtInput) {
const regex = /^[0-9]*$/;
if (regex.test(txtInput)) {
return true;
}
return false;
}
onChangePhoneNumberValidate(txtInput) {
const regex = /^[0-9+-]*$/;
if (regex.test(txtInput)) {
return true;
}
return false;
}
onChangeFreeTextValidate(txtInput) {
const regex = /[`~,.<>;':"\/\[\]\|{}()=_+-]/;
if (!regex.test(txtInput)) {
return true;
}
return false;
}
onChangeEmailValidate(txtInput) {
const regex = /^[a-zA-Z0-9.@]*$/;
if (regex.test(txtInput)) {
return true;
}
return false;
}
// Email Validation
isValidEmail(email) {
const regex = /^(([^<>()\[\]\\.,;:\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,}))$/;
if (!regex.test(email)) {
return false;
}
return true;
}
}
module.exports = new Validation();