3

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?

chama
  • 5,973
  • 14
  • 61
  • 77

1 Answers1

2

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:

bdoughan
  • 147,609
  • 23
  • 300
  • 400