I am trying to add string input to spring boot application. The content type is json and I am trying to add validation to it.
@RestController
@RequestMapping(value = "/entries")
public class SampleController {
@RequestMapping(method = RequestMethod.DELETE)
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void delete(@RequestBody @NotBlank(message = "{field.required}") String username) throws Exception {
//some logic
}
}
For some reasons, @Notblank
annotation does not work.
Is it right way to do it.