Binder Validation - disabled / readonly fields will not be validated

Do the binder have a possibility to disable the validation for fields which are disabled / readonly or not visible?

  1. Use-Case:
    Legacy Software, where a field was not mandatory in the past, but now the field is required. So if we open an old view in readOnly mode this field will be empty. If the user tries do navigate for example to the next subview, the validation for the fields is failing.
  2. Use-Case:
    If we have several input fields which depends on for example a CheckBox. If the CheckBox is checked, the input fields have to be filled. Otherwise the input fields can be empty. So the UI Design could be, if checkBox is checked disable the input fields. So the user knows, that no input is required. It would be also possible to make the input fields readOnly or not visible.

Is there a way to achieve this, with a bit of code.

From Vaadin 8.10 and Vaadin 14.1 onwards there is Binding#setAsRequiredEnabled(boolean) and from Vaadin 8.11 and possibly Vaadin 14.3 onwards there will be Binding#setValidatorsDisabled(boolean) methods for fine grained control of validation.