Add validation annotation for resources.

This commit is contained in:
robin shine 2013-10-12 10:26:26 +08:00
parent 26535f960a
commit f3332cfea0
2 changed files with 4 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package com.pmease.gitop.rest.resource;
import io.dropwizard.jersey.params.LongParam;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@ -36,7 +37,7 @@ public class ProjectResource {
}
@POST
public Long save(Project project) {
public Long save(@Valid Project project) {
projectManager.save(project);
return project.getId();
}

View File

@ -3,6 +3,7 @@ package com.pmease.gitop.rest.resource;
import io.dropwizard.jersey.params.LongParam;
import javax.inject.Inject;
import javax.validation.Valid;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@ -35,7 +36,7 @@ public class UserResource {
}
@POST
public Long save(User user) {
public Long save(@Valid User user) {
userManager.save(user);
return user.getId();
}