public static Validator validUrl() {
    return (name, val) -> {
      if (!(val instanceof String)) {
        throw new IllegalArgumentException("validator should only be used with STRING defs");
      }
      try {
        new URL((String)val);
      } catch (final Exception e) {
        throw new ConfigException(name, val, "Not valid URL: " + e.getMessage());
      }
    };
  }
@Test
  public void shouldThrowOnInvalidURL() {
    // Given:
    final Validator validator = ConfigValidators.validUrl();

    // When:
    final Exception e = assertThrows(
        ConfigException.class,
        () -> validator.ensureValid("propName", "INVALID")
    );

    // Then:
    assertThat(e.getMessage(), containsString("Invalid value INVALID for configuration propName: Not valid URL: no protocol: INVALID"));
  }