in src/main/java/org/apache/commons/validator/routines/InetAddressValidator.java [103:125]
public boolean isValidInet4Address(final String inet4Address) {
// verify that address conforms to generic IPv4 format
final String[] groups = IPV4_VALIDATOR.match(inet4Address);
if (groups == null) {
return false;
}
// verify that address subgroups are legal
for (final String ipSegment : groups) {
if (GenericValidator.isBlankOrNull(ipSegment)) {
return false;
}
int iIpSegment = 0;
try {
iIpSegment = Integer.parseInt(ipSegment);
} catch (final NumberFormatException e) {
return false;
}
if (iIpSegment > IPV4_MAX_OCTET_VALUE || ipSegment.length() > 1 && ipSegment.startsWith("0")) {
return false;
}
}
return true;
}