Customize display error message

I want to display the error message of validation of a field with a Label so as said in the doc i could use
.withStatusLabel
or
.withvalidationStatusHandler
but if i would want to keep the red border of the field or even the error indicator ! what should be do?

Hi,
you can use ValidationStatusHandler to update the label and even set component error for the text field

TextField text = new TextField();
Label status = new Label();

binder.forField(text).withValidator(...)
   .withValidationStatusHandler(statusChange -> {
     status.setValue(statusChange.getMessage().orElse(""));
     if (statusChange.isError()) {
       status.setValue(statusChange.getMessage().orElse(""));
       text.setComponentError(new UserError(""));
     } else {
       text.setComponentError(null);
       status.setVisible(statusChange.isError());
     }
   });

HTH
Marco

Thank you very much, Marco.
The trick was setComponentError ( i’ll have forgotten). I modify a little your code because my label was not visible in the form.

TexField text = new TextField;
Label status = new Label();
status.setVisible("false");

...
.withValidationStatusHandler(statusChange -> {
    status.setVisible(statusChange.isError());
    status.setValue(statusChange.getMessage().orElse(""));
    text.setComponentError( statusChange.isError() ?
           new UserError("") : null );    
})
...