-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormValidator.js
29 lines (29 loc) · 1.04 KB
/
FormValidator.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
class FormValidator {
static isValidEmail(string) {
let email_regex = /^([^"( )])+(\@)[a-z]+(\.)[a-z]+$/i;
return email_regex.test(string) ? true : false;
}
static isValidAddress(string) {
let address_regex = /^(No) [0-9]+, ?[a-z0-9 -]+, ?[a-z -]+, ?[a-z -]+\.?$/;
return address_regex.test(string) ? true : false;
}
static isValidFullname(string) {
let fullname_regex = /^([a-z]{2,})+( ([a-z]{2,})+)+$/i;
return fullname_regex.test(string) ? true : false;
}
static isValidUsername(string) {
let username_regex = /(^[a-z]+(?=[\d])|[0-9]+(?=[a-z]))[a-z0-9]+$/i;
return username_regex.test(string) ? true : false;
}
static isValidDate(string) {
let date_regex = /^(([0-2][0-9])|(3[0-1]))\-((0[1-9])|(1[1-2]))\-[0-9]{4}$/;
return date_regex.test(string) ? true : false;
}
static isValidWebsite(string) {
let website_regex = /^(https?:\/\/)?(www\.)?[^\[\]\{\}\|\\”%~#<> .]+\.[a-z]+$/;
return website_regex.test(string) ? true : false;
}
}
console.log(
FormValidator.isValidAddress('No 9, adekunle avenue cross,eti-osa lekki, lagos')
)