Provide a way to consider unknown union types invalid
Currently Jackson object mapper will happily deserialize an object with bogus union types. This is desirable in certain cases as it allows for additive changes. However, on the server side quite often we want to discard such objects.
Why can't you handle to UNKNOWN case explicitly in your code?
It's not a blocker, I can just generate a visitor and handle it explicitly.
However, the overhead is significant especially if that is the only validation one wants to perform on an object. In addition to that, the current behavior is error-prone as the validation has to be added every time new union is introduced.
For Java consumers, the expectation is that any union type is accessed through the visitor and you are explicitly forced to handle UNKNOWN by implementing the visitor. This is still true when a new union member is introduced.
That's true. The problem arrises if a server does not need to use the union on put but it needs to do something with it on get. In such case one has to implement 2 visitors which is quite verbose.