users@jaxb.java.net

Re: ValidationEventHandler returns only parent object through ValidationEvent.getLocator().getObject()

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Thu, 30 Sep 2004 13:41:18 -0700

jon gold wrote:
> one possibility would be to allow users to customize the validation
> messages through external bindings. ie, i could do something like
>
> <xsd:element name="foo" type="xsd:string">
>
> <jxb:validationDirective>
> <jxb:onMissing value="Need a 'foo'"/>
> <jxb:onInvalid value="'foo' must contain the string 'blubber'"/>
> </jxb:validationDirective>
>
> <xsd:restriction>
> <xsd:pattern value=".*blubber.*"/>
> </xsd:restriction>
>
> </xsd:element>
>
> then xjc could either create it's raw validator to put that in the
> ValidationEvents. the ValidationEvent class could be augmented with
> getCustomizedMessage(), so we can create our own validation failure
> messages, etc.

Isn't it easier/useful if you can do those things in your Java class? as
opposed to do them in the schema?

Maybe

        class Abc {
                @NeverNull
                @Pattern(".*blubber.*")
                private String foo;
        }

?

I guess you'd want another way to specify constraints outside the source
file, but hopefully you see what I'm trying to say...

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net