ARTICLE AD BOX
My application has the following properties
employeeEngine.callLegacy=true employeeEngine.callNewApi=trueI want to make it possible to call either only the legacy service, or the new api endpoint (to retrieve the same data) along with the legacy, or the new endpoint alone (without calling the legacy).
Only thing I don't want is to call neither of these!
I could do a simple custom validation myself in the business service (I am injecting the properties on class fields)
public class BusinessService { @Value("employeeEngine.callLegacy:true") private boolean callLegacy; @Value("employeeEngine.callNewApi:true") private boolean callNewApi; // constructor // public methods with business logic private boolean someInternalMethod() { if (!callLegacy && !callNewApi) { LOGGER.error("Bad!!"); throw new BusinessException("At least one of {callLegacy} or {callNewApi} should be set"); } } }But I feel like this kind of validation is better on a @ConfigurationProperties class for example.
Is this ok or are better ways to validate properties combinations?
NB: on a side note, is there a way to retrieve the property value for logging or for display on exception messages?
