Bean Validation 1.1 early draft 1 is out - time for feedback
After a long time in the shadows of open work... Ahem, take two. After a long time at work, I am very pleased to announce Bean Validation 1.1 early draft 1. This is our first big milestone since the release of 1.0.
The draft is making its way through the official channels of the JCP but we also wanted to release it in full openned. For people in a hurry, the spec draft is here.
What's new
We worked on three major areas:
- openess
- method level validation
- dependency injection
Openess
The specification, the reference implementation, the TCK, this website... everything is open sourced. All work done on Bean Validation 1.1 is done in the open either on the mailing list, the issue tracker or via GitHub pull requests. Check out more in the how to contribute section.
Method-level validation
You can now put constraints declarations on parameters and return values of methods and constructors.
@MethodValidated
public class OrderService {
public OrderService(@NotNull CreditCardProcessor creditCardProcessor) {
//...
}
public void placeOrder(
@NotNull @Size(min=3, max=20) String customerCode,
@NotNull @Valid Item item,
@Min(1) int quantity) {
//...
}
}
Interception frameworks like CDI will check these constraints upon method calls thanks to the
@MethodValidated
annotation. Read more in the spec.
Dependency injection
Bean Validation uses a few components MessageInterpolator
, TraversableResolver
, ConstraintValidatorFactory
and most importantly ConstraintValidator
. We have standardized how these objects are managed by a container
and how these objects can benefit from container services.
That means that your constraint validator implementation will be able to get resources injected automatically.
While we go into details on how it will fit in CDI and Java EE, we have worked hard to make it container agnostic. If you write or use other containers (Guice, Spring Framework, Avalon :) ), check out if it fits properly.
Contributions
We have had tremendous help from the Bean Validation community at large but I would like to give a massive thank you to Gunnar Morling who stepped up and lead the work on method-level validation. This is by far the biggest new feature of Bean Validation 1.1.
How to read the spec and provide feedback
The draft has been published here and all changes are marked with a different color. Green for additions, yellow for changes and struck through red for removals . This will help you see what has changed precisely.
Have feedback? Please talk to us either:
- on our mailing list
- in our issue tracker
- or on the Bean Validation forum
If you want to go to the next step and contribute, send us an email to the mailing list and read how to contribute.
Proposal for method validation added
The first draft of the proposal for method-level validation is online. The proposal covers the declaration of parameter as well as
return values constraints, extensions to the Validator
API, related additions to the meta-data API etc.
So check out the proposal document and let us know what you think, e.g. by sending your questions or remarks to the beanvalidation-dev mailing list.
We have introduced a new section of the website called proposals. This will include wiki-style, work in progress proposals for various features being worked on.
Check out the first proposal page describing ideas and open questions on how to propose
dependency injection in ConstraintValidator
instances.
Work on method level validation
The expert groups has begun its work on method-level validation. A feature that was drafted in the latest spec (appendix) but that we could nto finish in time.
You will be able to define constraints on parameters and your favorite interception technology (CDI, @Inject, AspectJ, Spring etc) will call Bean Validation.
The final approach is not fixed yet but it will look like this.
public class BidManager { public void placeBid(@Min(0) BigDecimal upTo) { ... } }
Want to know more? Join the expert group mailing list. Learn how.
The specification repository is released
The last piece of the puzzle is now in the open. I have just released the specification repository on GitHub.
The list of repositories for the spec are
- Specification repository
- Reference implementation repository
- API repository
- TCK repository
- This website source
Want to contribute? Learn how.
Latest news
Stay up to date, subscribe to the news feed.