I have the following code:
@RequestMapping(value = "/test", method = RequestMethod.POST)
public void test(@RequestParam(required= false) String fromDate,
@RequestParam(required= false) String toDate) {
}
The "rules" are:
- if fromDate and toDate are empty --> OK
- if fromDate has a value and toDate is empty --> OK
- if fromDate and toDate have value --> OK
- if fromDate is empty and toDate has a value --> NOT OK
It is possible to do that with custom Spring validations?
Something like...
@RequestParam(required = false)
@ValidateDependingOnAnotherField(field = "fromDate") String toDate
Thanks!