Rakesh
Rakesh

Reputation: 133

JSR 303 Bean Validation, validation define array values in XML

I'm trying to create a custom validation wherein I have defined the annotation to accept an array of Strings for example:

public @interface Enum {
    String message() default "{}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    String[] value();
}

where value is an array of Strings. In the annotation i can use it as @Enum(value={"ABC", "PQR"}) & i can also retrieve this information at runtime. But when i represent the same information in the xml format as.

<constraint annotation="com.customvalidation.Enum">
    <element name="value">ABC</element>
    <element name="value">PQR</element>
</constraint>

it doesn't work, does any body have idea on how to represent the array in XML..?

Upvotes: 0

Views: 981

Answers (1)

MaDa
MaDa

Reputation: 10762

Based only on reading the Hibernate validator docs, I think it should be:

<constraint annotation="com.customvalidation.Enum">
    <element name="value">
         <value>ABC</value>
         <value>PQR</value>
    </element>
</constraint>

Upvotes: 2

Related Questions