Skip to content

Error Message Provider for EnumInputReader with Numbered Values #24

@Jprnp

Description

@Jprnp

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:

private T getValueFromIndex(String sVal, TextTerminal<?> textTerminal) {
        try {
            int optIndex = Integer.parseInt(sVal);
            if (optIndex > 0 && optIndex <= this.possibleValues.size()) {
                return this.possibleValues.get(optIndex - 1);
            }
        } catch (NumberFormatException var4) {
        }

        textTerminal.executeWithPropertiesPrefix("error", (t) -> {
            textTerminal.print(this.getDefaultErrorMessage(sVal));
            textTerminal.println(" Enter a value between 1 and " + this.possibleValues.size() + ".");
        });
        textTerminal.println();
        return null;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions