Skip to content

Commit 9761ea7

Browse files
authored
Merge pull request #7 from Luis-Cruz/feature/PCT-7
Return false when the is no validator or when the country code is not valid PCT-7 #resolve
2 parents cdf1861 + c2183b2 commit 9761ea7

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/main/java/org/fenixedu/PostalCodeValidator.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,14 @@ public static Map<String, JsonObject> getValidatorMap() {
5353
* specified country code otherwise false.
5454
*/
5555
public static boolean isValidAreaCode(final String countryCode, final String postCode) {
56-
final String regex = fieldFor(countryCode, "Regex");
57-
final Pattern pattern = Pattern.compile(regex);
58-
final Matcher matcher = pattern.matcher(postCode);
59-
return matcher.matches();
56+
try {
57+
final String regex = fieldFor(countryCode, "Regex");
58+
final Pattern pattern = Pattern.compile(regex);
59+
final Matcher matcher = pattern.matcher(postCode);
60+
return matcher.matches();
61+
} catch (Error e) {
62+
return false;
63+
}
6064
}
6165

6266
/**

0 commit comments

Comments
 (0)