0

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..?

3
  • How does it relate to JPA (meaning Java Persistence API)? Commented Nov 17, 2011 at 14:00
  • I'm using the Bean Validation(JSR-303) that works with JPA. May be the title is misleading will edit it Commented Nov 17, 2011 at 14:15
  • Does anybody have any idea how to implement this? I'm stuck at this point Commented Nov 18, 2011 at 7:42

1 Answer 1

2

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.