Test currency string for validity
jasonab opened this issue · 1 comments
jasonab commented
Currently, when creating a CurrencyUnit from a String, the only way to know if that String is invalid is to catch an unchecked exception from the builder. It would be nice to have a boolean validator that would indicate whether or not a string is a valid currency code.
jodastephen commented
You can use this:
boolean valid = CurrencyUnit.registeredCurrencies().stream()
.map(CurrencyUnit::getCode)
.anyMatch(code -> code.equals("GBP"));
Adding methods for this would require potentially 6 new methods - one for each of
method.