chama
chama

Reputation: 6163

Is there a way to limit the length of a string from a jaxb class?

How do you specify facets for the xsd in an annotated jaxb java class?

I'd like to limit a String to only 1 character using annotations (and not from an xsd). Is this possible?

Upvotes: 3

Views: 2414

Answers (1)

bdoughan
bdoughan

Reputation: 149017

You can use an implementation of Bean Validation (JSR-303) for this use case. It allows you to specify validation rules via annotations or XML for object properties. Hibernate implemented the reference implementation:

Upvotes: 2

Related Questions