@@ -126,10 +126,14 @@ protected boolean read(BindingReader bindingReader, KeyMap<String> keyMap, Numbe
126
126
checkInput (input , context );
127
127
break ;
128
128
case OPERATION_EXIT :
129
- if (StringUtils .hasText (context .getInput ())) {
129
+ var num = parseNumber (context .getInput ());
130
+
131
+ if (num != null ) {
130
132
context .setResultValue (parseNumber (context .getInput ()));
131
- }
132
- else if (context .getDefaultValue () != null ) {
133
+ } else if (StringUtils .hasText (context .getInput ())) {
134
+ printInvalidInput (context .getInput (), context );
135
+ break ;
136
+ } else if (context .getDefaultValue () != null ) {
133
137
context .setResultValue (context .getDefaultValue ());
134
138
} else if (required ) {
135
139
context .setMessage ("This field is mandatory" , TextComponentContext .MessageLevel .ERROR );
@@ -161,14 +165,18 @@ private void checkInput(String input, NumberInputContext context) {
161
165
}
162
166
Number num = parseNumber (input );
163
167
if (num == null ) {
164
- String msg = String .format ("Sorry, your input is invalid: '%s', try again" , input );
165
- context .setMessage (msg , MessageLevel .ERROR );
168
+ printInvalidInput (input , context );
166
169
}
167
170
else {
168
171
context .setMessage (null );
169
172
}
170
173
}
171
174
175
+ private void printInvalidInput (String input , NumberInputContext context ) {
176
+ String msg = String .format ("Sorry, your input is invalid: '%s', try again" , input );
177
+ context .setMessage (msg , MessageLevel .ERROR );
178
+ }
179
+
172
180
public interface NumberInputContext extends TextComponentContext <Number , NumberInputContext > {
173
181
174
182
/**
0 commit comments