Validation for Contract for API

cbrune
cbrune used Ask the Experts™
on
If i have a rest controller in spring boot how can I validate the contract that comes in if certain values of the parameters need to have certain values??? ANy code examples are appreciated!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Distinguished Expert 2018
Commented:
Assuming that you have something like this:

@RequestMapping(value = "/contract", method = RequestMethod.POST, consumes = "application/json")
public void validateContract(@RequestBody final Contract contract) throws Exception {
   if (contract.getAmount() < 0) {
      throw new Exception("Wrong amount");
   }
}

Open in new window

Distinguished Expert 2018

Commented:
Valid comment.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial