class HttpContentSizeValidator implements ConstraintValidator<ValidHttpContentSize, String> {

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        LOGGER.info("content size validation was called. Value: {}", value);
        if (value == null) {
            return true;
        } else if (!value.startsWith("http")) {
            context.buildConstraintViolationWithTemplate(INVALID_URL_MSG).addConstraintViolation();
            return false;
        }
        try {
            Pair<StatusType, Integer> contentLength = httpHelper.getContentLength(value);
            if (!contentLength.getKey().getFamily().equals(Family.SUCCESSFUL)) {
                String msg = String.format(FAILED_TO_GET_BY_FAMILY_TYPE, value, contentLength.getKey().getReasonPhrase());
                context.buildConstraintViolationWithTemplate(msg).addConstraintViolation();
                return false;
            }
            return contentLength.getValue() > 0 && contentLength.getValue() <= MAX_IN_BYTES;
        } catch (Throwable throwable) {
            LOGGER.info("content size validation failed.", throwable);
            context.buildConstraintViolationWithTemplate(FAILED_TO_GET_WITH_EXCEPTION).addConstraintViolation();
        }
        return false;
    }

}