@Override public boolean isValid( CharSequence value, ConstraintValidatorContext constraintValidatorContext) { if (value == null || value.length() == 0) { return true; } ValueHolder values = parseUrl(value.toString()); if (values == null) { return false; } if (protocol != null && protocol.length() > 0 && !protocol.equals(values.getProtocol())) { return false; } if (host != null && host.length() > 0 && !host.equals(values.getHost())) { return false; } if (port != -1 && values.getPort() != port) { return false; } return true; }