Hi,
You can use XML as outlined by Vlad (or, the API for programmatic constraint declaration in Hibernate Validator).
I'd be interested in your rationale for avoiding that dependency, though. If you constrain your public API types, the constraints are part of the API, the user needs to adhere to these constraints (or they provide some form of guarantee to him, if e.g. constraining method return values). So IMHO it makes sense to expose the constraint information to API users as well (that's also the reason why all the Bean Validation constraint annotation types are meta-annotated with @Documented, which will cause them to be listed in JavaDocs of annotated elements). So it'd be interesting to learn more about your use case.
Btw. annotated classes can be loaded also if the annotation types are not present at runtime, so your API should still be usable also without the constraint annotation types (of course validation will not work then).
Cheers,
--Gunnar
_________________ Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/
|