I'm using Spring 4 and I need to validate my requests according to the type of the request.
I'm trying to validate my requests in Service layer(I don't know how can I do in controller or if I won't respect the single responsability pattern if I put this type of validation in Controllers layer).
Why?
I need to validate two or more types of requests like insert a new item, update, etc
Like:
@RequestMapping(value = "/insert", method = RequestMethod.POST)
public void insert(@RequestBody Entity entity)
In this case I want to use InsertEntityValidator
@RequestMapping(value = "/update", method = RequestMethod.POST)
public void update(@RequestBody Entity entity)
In this case I want to use UpdateEntityValidator
Custom validator is necessary because of Business Validation
I don't know the ways to do that.....