forked from mosip/mosip-config
-
Notifications
You must be signed in to change notification settings - Fork 3
/
credentialdata.mvel
52 lines (47 loc) · 1.29 KB
/
credentialdata.mvel
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
def convertDateFormat(value, inputformat, outputformat) {
import io.mosip.kernel.core.util.DateUtils;
import java.util.Date;
Date date=DateUtils.parseToDate(value, inputformat);
String formattedDate= DateUtils.formatDate(date, outputformat);
return formattedDate;
};
def convertToMaskData(maskData) {
int maskDataLength = 0;
char ch = '*';
if (maskData.indexOf("@") > 0){
maskDataLength = maskData.indexOf("@");
} else {
maskDataLength = maskData.length();
}
maskDataLength -= 2;
for (int i = 1; i < maskDataLength; ++i) {
maskData = maskData.substring(0, i) + ch + maskData.substring(i + 1);
}
return maskData;
};
def formatName(names) {
StringBuilder name = new StringBuilder("");
for (int i = 0; i < names.size(); i++) {
name.append(names[i]);
if(i < names.size() - 1) {
name.append(" ");
}
}
return name.toString()
};
def formatAddress(addressLines) {
StringBuilder address = new StringBuilder("");
for (int i = 0; i < addressLines.size(); i++) {
address.append(addressLines[i]);
if(i < addressLines.size() - 1) {
address.append(", ");
}
}
return address.toString()
};
def maskPhone(inputPhoneNum) {
return inputPhoneNum.replaceAll(".(?=.{4})", "*");
};
def maskEmail(inputEmailAddr) {
return inputEmailAddr.replaceAll("(^[^@]{3}|(?!^)\\G)[^@]", "$1*");
};