Supposing a type with the following definition:
I would expect Optional.empty() to generate no validation errors, because the value is not present. Certainly that's the way other constraints work. Unfortunately, what I get instead is:
'must not be blank'
It's pretty clear why this is happening:
...and since null isn't a valid value, it of course fails the validation. Any null-failing validator would complain at that point.
A more idiomatic way to deal with optionals would be something like:
...which would only call the receiver if it was present. However, that's only if the value was present, which is a behavior change, so I'm unsure of all the ramifications of that.
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T00:58:13-07:00)
Maven home: C:\tools\apache-maven\bin\..
Java version: 9.0.4, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk-9.0.4
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"