Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I specify a pattern constraint using JAXB annotations?

I'm developing a SOAP application using JAX-WS and JAXB. I'd like to specify a pattern constraint for one of the fields (a Dutch postcode, \d{4}[A-Z]{2}). That's very easy to do using xsd:pattern, but I can't find the equivalent JAXB annotation. How do I achieve this?

like image 859
Sietse Avatar asked Mar 01 '26 04:03

Sietse


1 Answers

You can't. The idea is to use JAXB annotations in combination with runtime validation against the schema, using javax.xml.validation.Schema, which can be plugged into the Marshaller and Unmarshaller.

like image 138
skaffman Avatar answered Mar 04 '26 08:03

skaffman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!