You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be great if we had the possibility to replace the standard "Enter a value between 1 and X" error message in the EnumInputReader. I'm developing an application in Portuguese, so the default english message doesn't fit well.
By debugging i found that there isn't any checks for a Message Provider in the method getValueFromIndex of class InputReader:
privateTgetValueFromIndex(StringsVal, TextTerminal<?> textTerminal) {
try {
intoptIndex = Integer.parseInt(sVal);
if (optIndex > 0 && optIndex <= this.possibleValues.size()) {
returnthis.possibleValues.get(optIndex - 1);
}
} catch (NumberFormatExceptionvar4) {
}
textTerminal.executeWithPropertiesPrefix("error", (t) -> {
textTerminal.print(this.getDefaultErrorMessage(sVal));
textTerminal.println(" Enter a value between 1 and " + this.possibleValues.size() + ".");
});
textTerminal.println();
returnnull;
}
The text was updated successfully, but these errors were encountered:
@Jprnp I released the version 3.4.0, which provides the method withInvalidIndexErrorMessagesProvider.
Usage example:
Month month = textIO.newEnumInputReader(Month.class)
.withInvalidIndexErrorMessagesProvider((val, propName, minIdx, maxIdx) ->
Arrays.asList(
"Sorry, but '" + val + "' is not a valid option.",
"Please enter an integer value between " + minIdx + " and " + maxIdx + "."
))
.read("What month were you born in?");
It would be great if we had the possibility to replace the standard "Enter a value between 1 and X" error message in the EnumInputReader. I'm developing an application in Portuguese, so the default english message doesn't fit well.
By debugging i found that there isn't any checks for a Message Provider in the method getValueFromIndex of class InputReader:
The text was updated successfully, but these errors were encountered: