validationMethods.js
1.41 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
export default class Validation{
validateEmail (value) {
// regex from http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
var re = /^(([^<>()[\]\\.,;:\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,}))$/;
return re.test(value);
};
noSpecialChars(str){
str = String(str);
return !/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g.test(str);
}
noQwertysAllowed (str){
str = String(str);
str = str.toLowerCase();
if(str.toLowerCase().IndexOf("qwerty") >-1){
return false;
} else{
return true;
}
}
passwordValidation (str){
str = String(str);
if(str.length <6){
return false;
} else{
return true;
}
}
isNumberOnly(str){
str = String(str);
if(!/^\d+$/.test(str)){
return false;
}else {
return true;
}
}
isValidACN(str){
str = String(str);
console.log(str);
if(/^\d+$/.test(str) && str.length ==9){
return true;
} else{
return false;
}
}
containsNumbers(str){
str = String(str);
if(/\d/g.test(str)){
return true;
}else{
return false;
}
}
isValidShortCode(str){
str = String(str);
if(containsNoSpecialCharacters(str) && !containsNumbers(str) && str.length <5){
return true;
} else{
return false;
}
}
};