Validation of incoming workflow arguments

Greetings. I am thinking about how to expose Temporal workflow definitions as internal-APIs.

An aspect of that is validation. As payloads into the Java SDK are processed, they’ll flow through the DataConverter implementations. In Java-world, obviously, validation is typically performed with javax.validation annotations (JSR-303/330, etc.). Where’s the best place to mandate/force validation for all incoming payloads/arguments? I considered an interceptor, though I’m not sure they’re designed to handle errors (e.g. throwing instances of TemporalFailure – I get weird behaviour if I try). Another idea might be to wrap the existing DataConverter instances to trigger validation after de-serialization. Or, we have to code it directly into the workflow implementations.

Any suggestions would be welcome. Thanks!

In my opinion if validation is part of your requirements (input values determine control flow logic) then it should be part of your workflow impl. Otherwise in your internal APIs that I assume use the Temporal SDK client apis you could do custom validation before starting a workflow execution.