How to validate a List with @DecimalMin and @DecimalMax?

前端 未结 1 1451
别那么骄傲
别那么骄傲 2021-01-16 07:54

In my Spring project I have a POJO class with a property for a CMYK color. I want this property to be represented by a JSON array with exactly 4 floating-point numbers. Each

相关标签:
1条回答
  • 2021-01-16 08:34

    We implemented container element constraints in Hibernate Validator 6.0.x.

    So upgrade to Hibernate Validator 6.0.x (6.0.9.Final is the latest) and Bean Validation 2.0.1 and do as follows:

    @Size(...)
    private List<@DecimalMin(...) @DecimalMax(...) BigDecimal> cmykColor;
    

    Be careful, the groupId of Hibernate Validator 6.0 is org.hibernate.validator.

    0 讨论(0)
提交回复
热议问题