admin@glassfish.java.net

Re: custom validator for configRef

From: Jennifer Chou <jennifer.chou_at_oracle.com>
Date: Mon, 20 Dec 2010 16:48:28 -0500

Yes this works.
public class ConfigRefValidator
    implements ConstraintValidator<ConfigRefConstraint, Server>, Payload {

But one of the unit test complained about the payload not returning an
empty array when I returned ConfigRefValidator.class as the default payload
public @interface ConfigRefConstraint {
    String message() default "{configref.invalid}";
    Class<?>[] groups() default {};
    Class<? extends Payload>[] payload() default {ConfigRefValidator.class};
}

Putting it here, however, seems to work:
@ConfigRefConstraint(payload=ConfigRefValidator.class)

I can see the proper message displayed.

On 12/20/2010 3:34 PM, Tom Mueller wrote:
> The Payload returned ConfigRefConstraint can any class or interface
> that implements the Payload interface that is in the same Java package
> as ConfigRefConstraint. Can you just make the
> ConfigRegConstraintValidator implement Payload and return that?
>
> Tom
>