Home

News: Road to Final: Bean Validation JSR 303 and Hibernate Validator 4

  1. JSR 303 Bean Validation and Hibernate Validator 4 (the reference implementation) are now in their last draft before final. Bean Validation standardizes constraint declaration, definition, validation and metadata for the Java platform. Said otherwise, add an annotation to a property and hop it's validated.
    class User { @NotEmpty @Size(max=50) String getName() { ... } @Email String getEmail() { ... } }
    Of course there are many many features like built-in constraints, custom constraint definition, constraint composition, groups for partial validation, internationalization and a metadata query API. Now is the time to play with it, Hibernate Validator 4 is aligned with the latest draft. Bean Validation will be part of Java EE 6 and has deep integration with Java Persitence 2 and Java Server Faces 2. But the spec is not tied to EE and can be used on any Java SE 5 environment. If you want to know more, go check what's new here and download Hibernate Validator 4 on sourceforge. Another somewhat outdated but still good resource is this list of blog entries. You can also find podcasts on the subject by the JavaPosse, Chariot TechCast and others. And please give us feedback in our forums and seriously start thinking constraint validation in your applications :)
  2. Excellent. Did some quick googlin'. I need to take good look at this.
  3. Looks interesting.. I was just looking for a validation framework and came across this. In particular I'm hoping more UI frameworks will be making use of this to generate client/server side validations. Here's a couple that look to be on the path: Wrote some more about this here
  4. Looks interesting.. I was just looking for a validation framework and came across this. In particular I'm hoping more UI frameworks will be making use of this to generate client/server side validations.

    Here's a couple that look to be on the path:


    Wrote some more about this here
    Actually JSF 2.0 does integrates with Bean Validation out of the box, I am very happy about that. MyFaces is adding some additional features and RichFaces push your constraint validatiosn to the client using a JavaScript translator. That's an approach we've drafted but could not standardize in JSF 2.0 by lack of time. But you are right, any presentation framework can use Bean Validation and I hope to see integration with all the major ones sooner than later.
  5. Looks interesting.. I was just looking for a validation framework and came across this. In particular I'm hoping more UI frameworks will be making use of this to generate client/server side validations.

    Here's a couple that look to be on the path:


    Wrote some more about this here


    Actually JSF 2.0 does integrates with Bean Validation out of the box, I am very happy about that. MyFaces is adding some additional features and RichFaces push your constraint validatiosn to the client using a JavaScript translator. That's an approach we've drafted but could not standardize in JSF 2.0 by lack of time.

    But you are right, any presentation framework can use Bean Validation and I hope to see integration with all the major ones sooner than later.
    Looking for GWT, SWT/JFace (Eclipse RCP) and Swing integration.
  6. Looking for GWT, SWT/JFace (Eclipse RCP) and Swing integration.
    There is a project implementing a 303 / GWT, google for it. For the other two, I am not aware of someone implementing the link between Bean Validation's error report and the UI library error report but I can't imagine that being but trivial. FTR the method used by JSF is validator.validateValue which allows validation of a value before it reaches the domain model. In a classic UI framework, this method would be triggered when the field is losing focus (or when the nbr of key press event has settled and the data is considered entered.
  7. Looking for GWT, SWT/JFace (Eclipse RCP) and Swing integration.


    There is a project implementing a 303 / GWT, google for it.

    For the other two, I am not aware of someone implementing the link between Bean Validation's error report and the UI library error report but I can't imagine that being but trivial.

    FTR the method used by JSF is validator.validateValue which allows validation of a value before it reaches the domain model. In a classic UI framework, this method would be triggered when the field is losing focus (or when the nbr of key press event has settled and the data is considered entered.
    Any binding framework between the UI component and the data model would make a perfect integration point too actually.
  8. There is a project implementing a 303 / GWT, google for it.
    I should have said "Will be looking ... "
  9. I have written a struts 1 jsr-303 integration library available at

    http://code.google.com/p/sbva/

    to allow easy integration of jsr-303 with struts 1. If you try it please let me know what you think.