Empty validatedBy in @Constraint

后端 未结 2 732
长情又很酷
长情又很酷 2021-02-04 03:11

I noticed that all built-in constraints have an empty value for the validatedBy parameter in @Constraint. i.e. @Constraint(validatedBy = {})

相关标签:
2条回答
  • Those built-in are treated in special implementation-specific way and their validators are configured programmatically.

    For Hibernate Validator it's done in ConstraintHelper.java. I think you can't achieve the same for your custom constraints.

    0 讨论(0)
  • 2021-02-04 03:36

    Maybe have a look at this answer:

    How to avoid cross dependency between layers because of @Constraint validatedBy?

    And those two links:

    Adding constraints programmatically: http://docs.jboss.org/hibernate/stable/validator/reference/en-US/html/validator-specifics.html#section-programmatic-api

    Adding constraints per xml: http://docs.jboss.org/hibernate/validator/4.1/reference/en-US/html/validator-xmlconfiguration.html

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