Help

It's my pleasure to announce the availability of Bean Validation TCK 1.1.0.CR1 and Hibernate Validator 5.0.0.CR1.

You can find the TCK

  • as Maven artifact in the JBoss Maven repository under the coordinates org.hibernate.beanvalidation.tck:beanvalidation-tck-tests:1.1.0.CR1 and
  • as distribution bundle (ZIP or TAR) on SourceForge

Hibernate Validator can be retrieved

These releases catch up with the proposed final draft of the Bean Validation 1.1 specification, which was handed over to the JCP just yesterday. Check out the announcement for an overview of what has changed feature-wise since the last Beta releases. We addressed 4 issues in the TCK and 16 issues in Hibernate Validator.

As there shall be no blog post without at least a little bit of source code, let's have a closer look at one of the new features, the XML-based configuration of method constraints, implemented with HV-373.

Let's assume there is a class OrderService like this:

public class OrderService {
    public Order placeOrder(String customerId, Item item, int quantity) {
        [...]
    }
}

The following shows an XML constraint mapping for adding method constraints to this class:

<?xml version="1.0" encoding="UTF-8"?>
<constraint-mappings
    xmlns="http://jboss.org/xml/ns/javax/validation/mapping"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.1.xsd"
    version="1.1">
    
    <default-package>com.acme.app.domain</default-package>

    <bean class="OrderService" ignore-annotations="false">
        <method name="placeOrder" ignore-annotations="true">
            <parameter type="java.lang.String">
                <constraint annotation="javax.validation.constraints.NotNull"/>
                <constraint annotation="javax.validation.constraints.Size">
                    <element name="value">5</element>
                </constraint>
            </parameter>
            <parameter type="Item">
                <valid/>
                <constraint annotation="javax.validation.constraints.NotNull"/>
            </parameter>
            <parameter type="int">
                <constraint annotation="javax.validation.constraints.Min">
                    <element name="value">1</element>
                </constraint>
            </parameter>
            <return-value>
                <valid/>
            </return-value>
        </method>
    </bean>
</constraint-mappings>

The following constraints are added here to the placeOrder() method:

  • The customerId parameter must not be null and must be at least five characters long
  • The item parameter must not be null and it is marked for cascaded validation (equivalent to annotating it with @Valid)
  • The quantity parameter must at least be 1
  • The method return value is marked for cascaded validation

What's next?

The final release of Bean Validation 1.1 is coming soon; in the mean time we'll work on more tests for the TCK, fix bugs as required in Hibernate Validator and polish the documentation.

You want to help? Nothing easier than that, just check out the proposed final draft of the specification and play around with all the new features using Hibernate Validator.

You found a bug? You think the implementation doesn't correctly obey to the specification? That's great! We look forward to your report in our issue tracker. You can also reach us via e-mail or in the commmunity forum.

4 comments:
 
21. Feb 2013, 22:52 CET | Link

Yeah! Good work keeping up with me despite my last second turns ;)

ReplyQuote
 
25. Jun 2014, 11:24 CET | Link

Trolleys at the same time offer a lot of budgets which really can be entered not having the removal of any container within the trolley.

 
09. Jul 2014, 05:31 CET | Link

It’s created by developers which determine what any buyer would like any time buying a artist carrier. Undoubtedly you need anywhere that will put the notebook, and you will in reality what things to become burberry replica, nevertheless they realize they will can’t merely glue items with each other and also put it around the corner. There has to be one thing special in regards to the bag that may ensure it is attracting replica rolex uk. They will supply each and every time, usually incorporating storage compartments, bracelets, and further chambers for you personally. Moreover, you’re more likely to acquire a fantastic warrantee away from any artist notebook replica chanel bags, rather than acquiring a single from your retailer, that may reduce one to ninety days or perhaps a smaller amount to get a substitute. Many developers offer you life span extended warranties on their notebook hand bags in the event you sign up that making use of their business; like that even when that dons out there by means of typical damage it is possible to nonetheless get yourself a alternative to totally free. This kind of characteristic on your own clearly helps it be worth the particular purchase. It is possible to use any african american from suppliers Chanel look-alike bag using a fit, any replica chanel, delicately together with denims plus a leading, or perhaps because the best match up to your wonderful little black dress.

 
10. Aug 2014, 15:05 CET | Link

Great post! I?m just starting out in community management/marketing media and trying to learn how to do it well - resources like this article are incredibly helpful. As our company is based in the US, it?s all a bit new to us. The example above is something that I worry about as well, how to show your own genuine enthusiasm and share the fact that your product is useful in that case.spekhargaponsel.com

Post Comment