In my controller, I have an object creation method
import javax.validation.Valid; ... @RestController public class Controller { @RequestMapping(method = RequestMethod.POST) public ResponseEntity<?> create(@Valid @RequestBody RequestDTO requestDTO) { ...
with
import org.hibernate.validator.constraints.NotEmpty; ... public class RequestDTO @NotEmpty // (1) private String field1;
I want to add a controller method
update(@Valid @RequestBody RequestDTO requestDTO)
but in this method, it must be acceptable for field1
be empty or zero, i.e. line
@NotEmpty
RequestDTO
should be ignored.
How can i do this? Should I write a class that looks exactly like RequestDTO
but does not contain annotations? Or is this possible through inheritance?
source share