Are you familiar with Java Validation API? And Spring validation? (if not, take a look at the end of this article for links to read)
In my practice I had an interesting case. The task was to implement an web endpoint accepting the request which body consisted of three fields. And only one of them must be specified at the time.