Binder Validation Details

Hi,

i have a rather complex form with multiple tabs. At the end i have a button to sign the form digitally. Before the user can sign the form i do some validation. Its a mix of binder validation an custom once.

For the binder i marked alle fields like this.

projekterfassungBinder.forField(projektbezeichnung).asRequired("Erforderlich").bind(Projekterfassung::getBezeichnung, Projekterfassung::setBezeichnung);

If someone clicks on sign i do this to check if all fiels are valid. If some field are not valid it will print this on the console but i dont get it how to check which field is not valid. At the end i like to replace the Print do a dialog which shows the user the Fields he need to fill with content

Dialog info = new Dialog();

BinderValidationStatus<Projekterfassung> binderValidationStatus = projekterfassungBinder.validate();
        if(!binderValidationStatus.isOk()){
            binderValidationStatus.getFieldValidationStatuses().forEach(status ->{
                if(status.isError()){
                    System.out.println("Fail Binding Validation");
                    info.add(new Div(status.label()));
                }
            });
        }else{
            binderAutoValidationOK = true;
        }

edit: there should be a method getField ln the ValidationStatus

Solved it now like this:

binderValidationStatus.getFieldValidationStatuses().forEach(status ->{
                if(status.isError()){
                    String label = (status.getField() instanceof HasLabel hasLabel) ? hasLabel.getLabel() : "Unbekanntes Feld";
                    autoValidationInfo.append(label).append(" ");
                }
            });