Vaadin Flow Validation with Spring Validator

i’ve a StateService.create and he throws a ValidationException with List<FieldError> (generated by DataBind @ Spring Validator), but i cannot set dynamically a custom error message for the form fields with Binder (Vaadin).

how i can solve this problem?

i made a workaround, but i need a generic solution because cast to TextField is really unstable…

for (FieldError fieldError : e.getErrors()) {
	Optional<?> fieldOption = binder.getBinding(fieldError.getField());
	if (fieldOption.isPresent()) {
		Binder.Binding<State, Object> stateBinding = (Binder.Binding<State, Object>) fieldOption.get();
		// FIXME: Fields(Component) should implements some interface like HasValidations
		((TextField) stateBinding.getField()).setErrorMessage(fieldError.getCode());