-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemailValidator.java
More file actions
33 lines (25 loc) · 835 Bytes
/
Copy pathemailValidator.java
File metadata and controls
33 lines (25 loc) · 835 Bytes
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
package org.amadeus.charon;
public class emailValidator {
public int validator(String mail){
int atIndex = 0;
int fullIndex = 0;
int count = 0;
atIndex = mail.indexOf('@', 0);
fullIndex = mail.indexOf('.', 0);
//To determine contains at least one .
if( mail.contains("."))
count++;
//To determine only one @ in email address
if(mail.indexOf('@', 0) == mail.lastIndexOf('@'))
count++;
//To determine only 2 or 3 characters behind .
if ((mail.length() - fullIndex -1 == 2) || (mail.length() - fullIndex -1 == 3)){
count++;
}
//To determine . behind @
if(atIndex < fullIndex) {
count++;
}
return count;
}
}