Help

I am happy to announce the first beta release of Hibernate Validator 4.2. You can download this release as usual from the JBoss Maven Repository or from SourceForge.

As announced earlier, the highlight of the 4.2 release is the implementation of method level constraints (HV-347) as described in Appendix C of the Bean Validation specification. Many thanks to Gunnar for implementing this new feature. Method level validation allows to apply constraints to method parameters or return values like this:

public @NotNull String saveItem(@Valid @NotNull Item item, @Max(23) BigDecimal price)
To validate these constraints you would get hold of a MethodValidator via the Validator.unwrap() method:
MethodValidator validator = Validation.byProvider( HibernateValidator.class )
    .configure()
    .buildValidatorFactory()
    .getValidator()
    .unwrap( MethodValidator.class );
and use one of the following methods of this new interface:
public interface MethodValidator {
    public <T> Set<MethodConstraintViolation<T>> validateParameter(T object, Method method, Object parameterValue, int parameterIndex, Class<?>... groups);
    public <T> Set<MethodConstraintViolation<T>> validateParameters(T object, Method method, Object[] parameterValues, Class<?>... groups);
    public <T> Set<MethodConstraintViolation<T>> validateReturnValue(T object, Method method, Object returnValue, Class<?>... groups);
}
The returned MethodConstraintViolation is derived from ConstraintViolation and provides additional method level validation specific information. For example it can contain the method name and index of the parameter which caused the constraint violation. The documentation for this feature is still work in progress and will be completed in the following releases.

We except that the new MethodValidator API is in particular interesting when used in conjunction with APIs or frameworks like Contexts and Dependency Injection (JSR-299) or aspect oriented frameworks. With the help of these frameworks it is very simple to create an interceptor/aspect which automatically triggers validation of all method invocations and throws a MethodConstraintViolationExcepion in case of any validation errors. Let us know how you are going to use this new API.

Next to method level validation we also introduced boolean composition for composed constraints (HV-390). So far composing constraints were always a conjunction of all specified constraints. With this release Hibernate Validator introduces the @ConstraintComposition annotation together with the CompositionType enum. This allows you to define composing constraints like this:

@ConstraintComposition(OR)
@Pattern(regexp = "K")
@Size(min = 2, max = 10)
@ReportAsSingleViolation
@Target({ METHOD, FIELD })
@Retention(RUNTIME)
@Constraint(validatedBy = { })
public @interface PatternOrSize {
	public abstract String message() default "OR";
	public abstract Class<?>[] groups() default { };
	public abstract Class<? extends Payload>[] payload() default { };
}
This is yet another contribution from the community. Thanks a lot for your support :)

Another new feature worth mentioning is the new ValueFormatterMessageInterpolator which allows you to interpolate the validated value in the message templates. To enable this new interpolator use the configuration API:

Validation.byProvider( HibernateValidator.class ).configure().messageInterpolator( new ValueFormatterMessageInterpolator() ).buildValidatorFactory();
Using the message parameter validatedValue and an optional format string you can interpolate the validated value. As example take a custom @Future constraint message - "${validatedValue:%1$td.%1$tm.%1$ty} is not in the future", which would interpolate into something like "13.01.11 is not in the future".

One note regarding backwards compatibility. Due to BVTCK-12 resp. HV-395 the javax.validation.Path implementation of Hibernate Validator needed some changes. The good news is, however, that unless you iterate over the Path instance returned by Constraint.getPropertyPath() you are not affected by this change.

Also the programmatic configuration of generic constraints has changes and looks like this now:

ConstraintMapping mapping = new ConstraintMapping();
mapping.type( Foo.class )
    .property( "bar", FIELD )
    .genericConstraint( MyConstraint.class ).param( "value", 1 );
We also added a new type parameter to ConstraintDef which simplifies the creation of definition types for custom constraints. It is now not longer necessary to provide methods for standard constraint attributes such as message(). If you are using a custom ConstraintDef you will have to retrofit your implementation.

Of course this release contains also a whole range of other bug fixes and improvements. You can view the full changelog here. Thanks to Kevin who helped to fix many of these issues. To point out one of his contributions have a look at HV-307 which adds support for Joda Time types such as DateTime. These types can be annotated with @Past and @Future just as the standard JDK date types.

We are looking forward to your feedback on the Validator Forum. For bug reports please use the issue tracker.

80 comments:
 
13. Jan 2011, 15:30 CET | Link

Very nice! Thanks Serli via Kevin for their contribution. Actually it looks like Hardy did nothing but integrate contributions ;)

ReplyQuote
 
13. Jan 2011, 21:41 CET | Link
Federico Mancini

Nice to see that the boolean composition made it in the new release :) Thanks again for the support!

 
13. Jan 2011, 21:46 CET | Link

Congratulations on the release. Is it just a drop-in-jar-replacement on AS 6 Final?

 
14. Jan 2011, 09:45 CET | Link
Nicklas Karlsson wrote on Jan 13, 2011 15:46:
Congratulations on the release. Is it just a drop-in-jar-replacement on AS 6 Final?

Yes, Only if you make extensive use of the Path API or if use the programmatic constraints configuration you might have to make some adjustments.

 
14. Jan 2011, 11:30 CET | Link
Hardy Ferentschik wrote on Jan 14, 2011 03:45:
Nicklas Karlsson wrote on Jan 13, 2011 15:46:
Congratulations on the release. Is it just a drop-in-jar-replacement on AS 6 Final?
Yes, Only if you make extensive use of the Path API or if use the programmatic constraints configuration you might have to make some adjustments.

And you don't drop in this baby, you gently put it in place. Be human!

 
14. Jan 2011, 13:00 CET | Link
Federico Mancini wrote on Jan 13, 2011 15:41:
Nice to see that the boolean composition made it in the new release :) Thanks again for the support!

We have to thank you guys for your contribution :)

 
16. Jan 2011, 22:48 CET | Link

Those interested in the method validation feature can find some more detail information in my blog post Method Validation with Hibernate Validator 4.2.

If you want to try method validation out yourself you might be interested in the methodvalidation-integration project I started on GitHub which provides validation interceptors for CDI and Google Guice.

As Hardy wrote we are happy about any feedback on the Beta, so just give it a try.

 
18. Jan 2011, 11:05 CET | Link
Gunnar wrote on Jan 16, 2011 16:48:
Those interested in the method validation feature can find some more detail information in my blog post Method Validation with Hibernate Validator 4.2.

Nice blog. I added the link as well to the wiki page Hibernate Validator on the Web. It already contains several links to articles and blogs about Validator.

 
21. Jan 2011, 14:05 CET | Link

BTW, has there been any discussion regarding hooks for client-side validation integration with JSR-303 in some MR?

10. Jun 2014, 12:58 CET | Link

Actual product packaging and materials may contain more and different information than what is shown on our website. We recommend that you do not rely solely on the information presented and that you always read labels, warnings, and directions before using or consuming a product. Please see our full disclaimer below. check out here

13. Jun 2014, 08:43 CET | Link

We also offer an in-house licensed esthetician services. We offer plastic surgery in Medford Oregon and it's surrounding areas.website link

03. Jul 2014, 18:53 CET | Link

This site is a leading resource for information about the James Bauer What Men Secretly Want PDF book that teaches you how to keep a guy interested and exactly what he needs in your relationship if he's going to stick around.what do all men secretly want

 
30. Jul 2014, 09:05 CET | Link

La moda e la magnificenza delle donne orologi è comunque una seconda richiesta pensato di prendere in considerazione in precedenza che l'acquisizione. Allora, siete attualmente attualmente alla ricerca di donne replica orologio con quadranti quadrati o sferiche, affare gigante con, retro, fondamentale, alla moda, comune, metallico, convenzionale, nero o bianco? Opzioni top-of-the-line per risolvere sul leader osservare ordinamento per lei personalmente personalmente può essere quello di considerare solo una avere una sembrare a totalmente diversa sembrare in genere, valutare e optare per la adattandosi favoloso ordinamento per delineare il vostro personaggio.

30. Jul 2014, 11:09 CET | Link

There isn't any more grueling form of fast or perhaps cleansing diet when compared to a pure h2o fast. With this fast, it is possible to only have got water. In accordance with many choice health professionals, the health improvements can become extraordinary.information

31. Jul 2014, 08:40 CET | Link

This course came from the fact that Bobby and Rob continually got questions from guys that started with “So, there is this girl…” Most guys completely blow it with the girls they really like.theofficialwebsite.co/bobby-rio-and-rob-judge-unlock-her-legs-review/

31. Jul 2014, 11:16 CET | Link

Costa Rican real estate has been, and continues to be, a good investment because the country has a very stable political system and a growing economy.Of course, Costa Rica has felt the impact of the severe economic downturn in the States and Europe.jaco homes for sale

 
31. Jul 2014, 14:38 CET | Link
Sonsa

I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it. the venus factor

01. Aug 2014, 14:40 CET | Link

The Doggy Dan Online Dog Trainer has the unique distinction of being the world's only video based dog training website endorsed by the Society for the Prevention of Cruelty to Animals (SPCA) and many dog owners are having great results using Doggy Dan's training methods.online dog trainer program reviews

02. Aug 2014, 12:53 CET | Link

Many experts including buyers of Lake Life EC note that the site is a premium site for sale as it is very near to many schools available in the Jurong Lake District. Also, many amenities are also near Lake Life EC such as the Japanese Garden, Chinese Garden as well as Jurong Lake Part. Residents of Lake Life EC will get to enjoy the facilities and amenities right in the heart of Jurong.jurong lakelife ec

 
09. Sep 2014, 09:17 CET | Link
asadalikhatri

3 PXL Photography - Las Vegas, Nevada. USA. Wedding photography company.Las Vegas Wedding Photographers

 
09. Sep 2014, 09:32 CET | Link
asadalikhatri

Modern signage depends on words which are used with images. At times modern signage designed for international audience omits text. You can promote your business with the help of custom made signage.Web Design

11. Sep 2014, 14:23 CET | Link
asadalikhatri

Thanks for sharing this interesting blog with us.My pleasure to being here on your blog..I wanna come beck here for new post from your site. serangoon condo

12. Sep 2014, 06:30 CET | Link

The Oxygen Miracle Cure book is only available online through author Kevin Richardson's website and is NOT sold through Amazon, Barnes and Noble, or other traditional book sellers.https://rebelmouse.com/oxygenmiraclecurereviews/

12. Sep 2014, 12:05 CET | Link

Manifestation Miracle by Heather Mathews is a digital product and can be downloaded instantly after purchase in PDF (ebook) format or viewed directly online using your favorite web browser.https://rebelmouse.com/manifestationmiraclereviews/

12. Sep 2014, 12:41 CET | Link

Thanks for sharing this interesting blog with us.My pleasure to being here on your blog..I wanna come beck here for new post from your site. elektronik sigara

13. Sep 2014, 12:30 CET | Link

At the end of the day, I believe it's the consumer's responsibility to do their own due diligence before investing in any program, but I definitely want to share with you what I've discovered during my own research in case it helps.capture his heart and make him love you forever ebook reviews

14. Sep 2014, 08:24 CET | Link

Includes a collection of Michael Fiore Text The Romance Back reviews, PDF download information, and romantic texting tips from around the web.text the romance back michael fiore book review

16. Sep 2014, 10:28 CET | Link

Gain instant access to the natural and weird anti-inflammatory system for safely and permanently shrinking and eliminating nasal polyps with the help of world-renowned bio-medical researcher, health consultant, nutritionist, and author, Manuel Richards.how to destroy nasal polyps without surgery

17. Sep 2014, 11:04 CET | Link

The Customized Fat Loss For Men program is compatible with desktop and laptop computers, iPhones, iPads, and virtually any tablet, smart phone, or other device that has PDF viewing capabilities.specificazioni

17. Sep 2014, 21:13 CET | Link

The 101 Superfoods That Stop Your Joint Pain book is only available online through author Mike Westerdal's website and is NOT sold through Amazon, Barnes and Noble, or other traditional book sellers.https://www.rebelmouse.com/101superfoodsthatstopjointpain/

20. Sep 2014, 10:57 CET | Link

The first is the program you see here on this site, Restore My Vision Today (sometimes also called Perfect Vision Today) by Dr. Sen and Samantha Pearson which was just recently released in April 2014. The second is called Vision Without Glasses by Duke Peterson which has been around for years, is extremely popular, and is currently ranked as the 1 natural vision improvement guide in the Clickbank Marketplace.can you correct your vision without glasses

22. Sep 2014, 16:41 CET | Link

The emotional contagion concept that Dr. T. teaches is based on actual scientific research that makes it possible for you to make your emotions contagious to her, much like how a yawn by someone in a room can be contagious and can cause everyone else in the room to also yawn.www ebookreviews ning

 
22. Sep 2014, 20:13 CET | Link
asadalikhatri

Excellent site, where did you come up with the information in this write-up? I'm glad I found it though, ill be checking back soon to see what other articles you have.waterbay upper serangoon

 
23. Sep 2014, 14:00 CET | Link
asadalikhatri

Potential home owners get the chance to connect to the close by upcoming Paya Lebar Square that is a simple drive away for some family entertainment and events. A really extraordinary life-style is waiting for you.urban oasis guocoland

25. Sep 2014, 13:54 CET | Link
erfahren Sie mehr

Folkersystem Vert Shock: Adam Folker And Justin 'Jus Fly' Darlington Reveal An Insane Method To Pump Up Your Vertical By 9-15 Inches And Throw Down Dunks On Helpless Defenders Like A Total Badass... erfahren Sie mehr

 
29. Sep 2014, 19:39 CET | Link

hello this nice very very also :)elektronik sigara

 
30. Sep 2014, 16:26 CET | Link
singhaiyi new ec

Excellent site, where did you come up with the information in this write-up? I’m glad I found it though, ill be checking back soon to see what other articles you have.singhaiyi new ec

02. Oct 2014, 07:36 CET | Link

ClBelow you will find the important facts and figures I feel every consumer should know surrounding Claire Casey's Capture His Heart book and complete training system for attracting and winning the love of the man you wacapture his heart and make him love you forever ebook reviews nt.ick HELP for text formatting instructions. Then edit this text and check the preview.

03. Oct 2014, 07:45 CET | Link

I was very encouraged to find this site. I wanted to thank you for this special read. I definitely savored every little bit of it and I have you bookmarked to check out new stuff you post. Mad ud af huset

 
03. Oct 2014, 12:51 CET | Link
Asadalikhatri

This is an excellent post. I have ever seen thanks to share it. It is really what I wanted to see hope in future you will continue for sharing such a excellent post.מנעולן בחולון

 
04. Oct 2014, 10:57 CET | Link
Discover new people

It's a great tool to connect, communicate and Making friends by sharing your music, photos, blogs and videos.Discover new people

 
04. Oct 2014, 13:43 CET | Link

I say thank you to the creator of this article, Efek pemakaian crystal x this article contains information that is very helpful for readers smeua especially my own. I'm waiting for the other information that is not less interesting. Good luck to you. visit our website to increase knowledge Crystal X NASA

 
07. Oct 2014, 12:19 CET | Link
buy facebook likes cheap

Very nice blog and articles. I am realy very happy to visit your blog. Now I am found which I actually want. I check your blog everyday and try to learn something from your blog. Thank you and waiting for your new post.buy facebook likes cheap

11. Oct 2014, 08:24 CET | Link

CliBelow you will find the important facts and figures I feel every consumer should know surrounding Claire Casey's Capture His Heart book and complete training system for attracting and winning the love of the man you want.capture his heart and make him love you forever ebook reviews ck HELP for text formatting instructions. Then edit this text and check the preview.

11. Oct 2014, 12:08 CET | Link

And no, we don't know where it will lead. We just know there's something much bigger than any of us here. Money Saving Blog

24. Oct 2014, 18:23 CET | Link

Thanks for sharing this interesting blog with us. My pleasure to being here on your blog..I wanna come back here for new post from your site. anyOption

25. Oct 2014, 08:51 CET | Link

The goal of this site is to provide Men and Shemales a place to Meet Locals and exchange emails. After getting to know each other. For more info, San Antonio decks

28. Oct 2014, 01:20 CET | Link

I conceive you have remarked some very interesting points , appreciate it for the post. elektronik sigara tr

 
28. Oct 2014, 06:30 CET | Link

Incredible post! I am really getting prepared to over this data, is extremely useful my companion. Likewise extraordinary blog here with the greater part of the important data you have. Keep doing awesome doing here elektronik sigara cesitleri

 
11. Nov 2014, 20:14 CET | Link
jack

and as our research shows, they are ahead in critical cosmetic dentist tequesta thinking skills, problem solving skills, as well as speaking and leadership skills

 
15. Nov 2014, 00:16 CET | Link
alikhan

I most likely appreciating each and every bit of it. It is an incredible site and decent impart. I need to much obliged. Great employment! You all do an incredible blog, and have some extraordinary substance. Keep doing awesome.formazione livorno

 
17. Nov 2014, 11:44 CET | Link
alikhan

Really impressed! Everything is very open and very clear clarification of issues. It contains truly facts. Your website is very valuable. Thanks for sharing. It's late finding this act. At least, it's a thing to be familiar with that there are such events exist. I agree with your Blog and I will be back to inspect it more in the future so please keep up your act.Erfolgsmacher

 
17. Nov 2014, 13:12 CET | Link

In Golf Thailand are situated total above the outback, from the rugged mesa panoramas in the north to the surprising coastal tendency in the south, as well as the facile-to-approach metropolitan districts such as Pattaya.A profuse besides hot nation giving the ideal contexts for golf Thailand is an fascinating Shangri-la which gives the splendid contemptible for both golf moreover numerous else activities over.

 
26. Nov 2014, 09:13 CET | Link
rozi

I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work. unsecured small business loans new york

 
27. Nov 2014, 22:45 CET | Link
rozi

Easily, the article is actually the best topic on this registry related issue. I fit in with your conclusions and will eagerly look forward to your next updates. Just saying thanks will not just be sufficient, for the fantasti c lucidity in your writing. I will instantly grab your rss feed to stay informed of any updates.transport kamienia krakow

 
27. Nov 2014, 23:26 CET | Link
rozi

It has fully emerged to crown Singapore's southern shores and undoubtedly placed her on the global map of residential landmarks. I still scored the more points than I ever have in a season for GS. I think you would be hard pressed to find somebody with the same consistency I have had over the years so I am happy with that.ogloszenia samochodowe

 
28. Nov 2014, 09:49 CET | Link
yurtdışı eğitim

olarak basarılar dileriz.

 
28. Nov 2014, 10:39 CET | Link
Ertesi gün

Doğum kontrol hapları, iğneler, deri yama testi, doku aşısı ve RİA (rahim içi araç) içerir. Ayrıca, az miktarda hormonun salınmasını sağlayan bir rahim içi aracı bulunmaktadır

 
30. Nov 2014, 22:00 CET | Link
rozi

Glad to chat your blog, I seem to be forward to more reliable articles and I think we all wish to thank so many good articles, blog to share with us. I will really appreciate the writer's choice for choosing this excellent article appropriate to my matter.Here is deep description about the article matter which helped me more.Website

01. Dec 2014, 08:49 CET | Link

İnşaat firmalarının ilk hedefi uygun fiyatlı ev yapmaktır, Bizim ilk hedefimiz ise en kaliteli ve dayanıklı daireleri yaparak siz değerli müşterilerimiz için en uygun fiyatlar ile satışa çıkarabilmektir.

 
02. Dec 2014, 09:53 CET | Link
jack

Awesome blog. I enjoyed reading your articles. This is truly a cosmetic dentist tequesta great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!

 
03. Dec 2014, 08:19 CET | Link
alikhan

I most likely appreciating each and every bit of it. It is an incredible site and decent impart. I need to much obliged. Great employment! You all do an incredible blog, and have some extraordinary substance. Keep doing awesome.lucid dreaming

 
03. Dec 2014, 16:22 CET | Link

Thanks you very much for sharing these links. Will definitely check this out.. happy new year 2015

 
04. Dec 2014, 14:29 CET | Link

The information you have posted is very useful. The sites you have referred was good. Thanks for sharing... Clenbuterol

 
06. Dec 2014, 10:33 CET | Link
rozi

This post is really magnificent. I really like this post. It is one of the best posts that I’ve read in a long time. Thanks a lot for this really good post. I really appreciate it!lucid dreaming

 
06. Dec 2014, 19:07 CET | Link

hello!! Very interesting discussion glad that I came across such informative post. Keep up the good work friend. Glad to be part of your net community. unoccupied property insurance Rd

 
12. Dec 2014, 11:35 CET | Link

Its a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that The content of your post is awesome Great work. 高雄咖啡

 
12. Dec 2014, 19:43 CET | Link

I have read your article, it is very informative and helpful for me.I admire the valuable information you offer in your articles. Thanks for posting it.. Find Coupon Codes

 
12. Dec 2014, 19:56 CET | Link

Interesting topic for a blog. I have been searching the Internet for fun and came upon your website. Fabulous post. Thanks a ton for sharing your knowledge! It is great to see that some people still put in an effort into managing their websites. I'll be sure to check back again real soon. Online Coupons

 
12. Dec 2014, 20:21 CET | Link

Very nice article, I enjoyed reading your post, very nice share, I want to twit this to my followers. Thanks!. Discount Codes

 
13. Dec 2014, 09:34 CET | Link
rozi

Really appreciate this wonderful post that you have provided for us.Great site and a great topic as well i really get amazed to read this. Its really good.Villas in Greater Noida

 
15. Dec 2014, 13:42 CET | Link

useful information on topics that plenty are interested on for this wonderful post.Admiring the time and effort you put into your b!.. sigle neon

 
16. Dec 2014, 16:05 CET | Link
rozi

I am always searching online for articles that can help me. There is obviously a lot to know about this. I think you made some good points in Features also. Keep working, great job !Express

 
16. Dec 2014, 16:39 CET | Link
rozi

Gangaur Realtech is a professionally managed organisation specializing in real estate services where integrated services are provided by professionals to its clients seeking increased value by owning, occupying or investing in real estate. I am impressed by the information that you have on this blog. It shows how well you understand this subject.Bodas

 
16. Dec 2014, 17:20 CET | Link
rozi

Really impressed! Everything is very open and very clear clarification of issues. It contains truly facts. Your website is very valuable. Thanks for sharing. It's late finding this act. At least, it's a thing to be familiar with that there are such events exist. I agree with your Blog and I will be back to inspect it more in the future so please keep up your act.Klener

 
17. Dec 2014, 11:16 CET | Link
rozi

Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained!Crap!Nocrap

 
17. Dec 2014, 11:53 CET | Link

Great article Lot's of information to Read...Great Man Keep Posting and update to People..Thanks Best epilator comparison chart

 
17. Dec 2014, 21:13 CET | Link

Nice to read your article! I am looking forward to sharing your adventures and experiences. Anna

 
17. Dec 2014, 21:36 CET | Link
jhonalex | asdad(AT)gmail.com

It is imperative that we read blog post very carefully. I am already done it and find that this post is really amazing. internetovy marketing

 
18. Dec 2014, 20:37 CET | Link

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking. dental plans for individuals

Post Comment