Java String validation using enum values and annotation

后端 未结 8 1505
暖寄归人
暖寄归人 2020-11-30 23:47

I want to validate a string against a set of values using annotations.

What I want is basically this:

@ValidateString(enumClass=com.co.enum)
String d         


        
8条回答
  •  一向
    一向 (楼主)
    2020-12-01 00:26

    You can use @NotNull annotation in conjunction with yours. To use that you need to add @Target( { ANNOTATION_TYPE }) annotation in ValidateString.

    http://docs.jboss.org/hibernate/validator/4.0.1/reference/en/html/validator-customconstraints.html

提交回复
热议问题