0

I'm working in a spring-cloud environment. The company has decided to pull all common code into a common module (.jar) to be added as a dependency to all applications. All the applications are consumers of a common message. I have been tasked with coming up with a way to validate this message on each individual application, because the message will have different validation requirements depending on which application receives it. For example, let's say we have a message for automobiles. If the automobile in question is a Ford F-150, it will have validation requirements for towing capacity, while the Honda Civic will have validation requirements for fuel savings. So the message coming in will be placed on an object in the common module, is there a way to create custom class-level validation specific to each individual application? The problem I'm running into now is that I am unable to declare the validatedBy class on the @constraint annotation at runtime. Has anyone ever faced this issue? Does anyone know how to create custom validation for an object in a common jar file? Thanks in advance.

Some additional information. I should also mention, the reason I'm looking at doing it this way is because the team that controls the validation for one vehicle, will not always be the team that controls the validation for another. That is why I'm trying to find a way to keep the validation living in the specific applications and not the common included jar.

stirling
  • 143
  • 2
  • 3
  • 8

1 Answers1

0

I ended up using spring-AOP to implement the validation. Just in case anyone runs into this issue, that is how I got this working.

stirling
  • 143
  • 2
  • 3
  • 8