Clean Code From the Trenches: Validation

Clean Code From the Trenches: Validation

http://ift.tt/2qiSOUp

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:

@RestController
@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;
    }

    @PostMapping
    public void doSomething(@Valid @RequestBody OrderDTO order) {
        orderService.createOrder(order);
    }
}

java

via DZone.com Feed https://dzone.com

May 15, 2017 at 11:27AM

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s