I want to add @NotEmpty in @RequestBody, but i don't want to create additional POJO just for the request, how can i do that?
I want to do like the following, but it still return me 201 Created status code when i put [] in request body, it means that @NotEmpty is actually not working.
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public void create(@Valid @NotEmpty @RequestBody Set<String> request) {
.....
}
I DO NOT WANT to do something like this, but the @NotEmpty works in this case :
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public void create(@Valid @NotEmpty @RequestBody SampleRequest request) {
.....
}
SampleRequest class
public class SampleRequest {
@NotEmpty
private Set<String> name;
..Setter and Getter
}