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(expected = IllegalArgumentException.class)
  public void shouldThrowOnNonStringFromParse() {
    // Given:
    final Validator validator = ConfigValidators.parses(parser);

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