最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - JSR bean validation not kicking in for primitive type collection - Stack Overflow

programmeradmin1浏览0评论

My controller looks something like this;

@PostMapping(path = RequestMappingConstants.CALCULATE_INTEREST, consumes = MediaType.APPLICATION_JSON_VALUE)
private ResponseEntity<Response> execute(@Valid @RequestBody @Size(min = 1) List<Long> Ids)
            throws BusinessException {
    this.processService.execute(Ids);
    return ResponseEntity.ok(Response.builder().build());
}

I tried using other validations like @Notnull @NotBlank etc but the validations are not getting invoked.

I do not have the option to wrap List<Long> Ids inside a Bean / DTO since my requirement is to make sure the request looks something like this;

[1L,2L,3L]

Creating a custom validation from JSR does not get invoked either, any ideas or suggestions to do these validations based on best practices ?

发布评论

评论列表(0)

  1. 暂无评论