|
@@ -10,6 +10,7 @@ import org.springframework.http.ResponseEntity;
|
10
|
10
|
import org.springframework.web.bind.annotation.*;
|
11
|
11
|
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
|
12
|
12
|
|
|
13
|
+import javax.validation.Valid;
|
13
|
14
|
import java.net.URI;
|
14
|
15
|
|
15
|
16
|
@RestController
|
|
@@ -29,7 +30,7 @@ public class PollController {
|
29
|
30
|
}
|
30
|
31
|
|
31
|
32
|
@RequestMapping (method=RequestMethod.POST)
|
32
|
|
- public ResponseEntity<?> createPoll(@RequestBody Poll poll) {
|
|
33
|
+ public ResponseEntity<?> createPoll(@RequestBody @Valid Poll poll) {
|
33
|
34
|
URI newPollUri = ServletUriComponentsBuilder
|
34
|
35
|
.fromCurrentRequest()
|
35
|
36
|
.path("/{id}")
|
|
@@ -49,7 +50,7 @@ public class PollController {
|
49
|
50
|
}
|
50
|
51
|
|
51
|
52
|
@RequestMapping(value="/polls/{pollId}", method=RequestMethod.PUT)
|
52
|
|
- public ResponseEntity<?> updatePoll(@RequestBody Poll poll, @PathVariable Long pollId) {
|
|
53
|
+ public ResponseEntity<?> updatePoll(@RequestBody @Valid Poll poll, @PathVariable Long pollId) {
|
53
|
54
|
// Save the entity
|
54
|
55
|
verifyPoll(pollId);
|
55
|
56
|
Poll p = pollRepository.save(poll);
|