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
If you set a range for a number field and enter an invalid value, there is no error message shown, because the validation result returns an empty error message.. It is not possible to do a custom validation because that validation is not triggered, after the default validator has failed.
Expected outcome
Either the default validator should be triggered after all custom validators have been fired, or the validation result should contain all errors...
Or: custom error messages for Min/Max should be possible for the number fields.
Minimal reproducible example
VerticalLayoutlayout = newVerticalLayout();
IntegerFieldfield = newIntegerField();
field.setMin(50); // for this test, other values than custom validatorfield.setMax(250);
Buttonbutton = newButton("validate");
layout.add(field, button);
Binder<TestObject> binder = newBinder<>();
binder.forField(field)
.withValidator((v, ctx) -> {
if (v == null) {
returnValidationResult.ok();
}
if (v < 100 || v > 200) {
returnValidationResult.error("not valid");
}
returnValidationResult.ok();
})
.bind(TestObject::getValue, TestObject::setValue);
button.addClickListener(e -> {
BinderValidationStatus<TestObject> state = binder.validate();
if (state.hasErrors()) {
Stringmsg = state.getValidationErrors().stream()
.map(ValidationResult::getErrorMessage).collect(Collectors.joining("\n"));
Notification.show(msg);
}
});
Steps to reproduce
if you enter the value 40, nothing is shown, because the default validator of the integer field is triggered. The custom validator does nothing.
If you enter the value 50, the "not valid" message is shown, because the custom validator is triggered.
Environment
Vaadin version(s): 24.3.5
OS: win10
Browsers
Issue is not browser related
The text was updated successfully, but these errors were encountered:
@yuriy-fix
problem is, that I don't want to skip all default validators at the binder, because "some" of the validators make sense... Skipping this validator would be better for my use case, because I only use the min/max attributes at client side.
@knoobie
adding additional messages would be great. But in my oppinion the custom validation should be also preferred against the default-validator, if only one error message is shown.
Same problem with "asRequired()" at the binder, but at least you can add a custom message there.
The binder works by "stopping" at the first error; therefore the default validation of the field (with no error message) is triggered before your validation runs, so this kind of precedence is currently not there.
Description
If you set a range for a number field and enter an invalid value, there is no error message shown, because the validation result returns an empty error message.. It is not possible to do a custom validation because that validation is not triggered, after the default validator has failed.
Expected outcome
Either the default validator should be triggered after all custom validators have been fired, or the validation result should contain all errors...
Or: custom error messages for Min/Max should be possible for the number fields.
Minimal reproducible example
Steps to reproduce
if you enter the value 40, nothing is shown, because the default validator of the integer field is triggered. The custom validator does nothing.
If you enter the value 50, the "not valid" message is shown, because the custom validator is triggered.
Environment
Vaadin version(s): 24.3.5
OS: win10
Browsers
Issue is not browser related
The text was updated successfully, but these errors were encountered: