Clean Code From the Trenches: Validation

Clean Code From the Trenches: Validation

Let’s start with an example. Consider a simple web service that allows clients to place an order to a shop. A very simplified version of the order controller could look something like below:

@RequestMapping(value = "/",
    consumes = MediaType.APPLICATION_JSON_VALUE,
    produces = MediaType.APPLICATION_JSON_VALUE)
public class OrderController {
    private final OrderService orderService;

    public OrderController(OrderService orderService) {
        this.orderService = orderService;

    public void doSomething(@Valid @RequestBody OrderDTO order) {


via Feed

May 15, 2017 at 11:27AM


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s