Validation for Contract for API

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!
cbruneAsked:
Who is Participating?
 
girionisCommented:
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

0
 
girionisCommented:
Valid comment.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.