The default value of the field while read() is “”.
If I don’t click the field - form submitting is ok.
If I click the field - form fires validation error.
How to fix it?
jakarta.validation.constraints.NotNull is a validation constraint, so it is only considered when running validation.
org.jspecify.annotations.NonNull tells tools such as IDEs or the Hilla generator that they can expect the field to never have null as a value.
In any case, if you want a Hilla form to automatically initialize a non-null field with an empty string, then use one of the annotations listed here: How to manage type nullability in Hilla | Vaadin
I have hit this issue too when using the Form within Auto Crud - a field, such as a nullable UUID field, will be initialised as null, however clicking on it changes it to an empty string, at which point form submission fails validation on the server.
The TextField’s default value is an empty string. On my experience is not capable to be set null. When a value change event is triggered, the value will never be null or undefined, even when the field is not required.