public static Validator parses(final Function<String, ?> parser) {
    return (name, val) -> {
      if (val != null && !(val instanceof String)) {
        throw new IllegalArgumentException("validator should only be used with STRING defs");
      }
      try {
        parser.apply((String)val);
      } catch (final Exception e) {
        throw new ConfigException("Configuration " + name + " is invalid: " + e.getMessage());
      }
    };
  }
@Test
  public void shouldPassStringsToParser() {
    // Given:
    final Validator validator = ConfigValidators.parses(parser);

    // When:
    validator.ensureValid("propName", "value");

    // Then:
    verify(parser).apply("value");
  }