I need to determine type of constraint violation from
[ConstraintViolation][1] object.
one way is to use `ConstraintViolation#getPropertyPath()`. If `getName()`
returns null on the `leaf` node you have a class level constraint,
otherwise a property level constraint.


One option is like

     Iterator<Node> violationNodes=violation.getPropertyPath().iterator();
        Node leafNode=null;
        while (violationNodes.hasNext()){
            leafNode=violationNodes.next();
        }

        if(leafNode!=null){
        // property constraint
        }
        else{
         // class constraint
        }


Is this good approach to determine or there can be other efficient or good
approach to do this?

-- 
With Regards
Umesh Awasthi
http://www.travellingrants.com/

Reply via email to