@@ -646,43 +646,34 @@ private function stepThroughGroupSequence($value, $object, MetadataInterface $me
646
646
*/
647
647
private function validateNodeForGroup ($ value , $ objectHash , MetadataInterface $ metadata = null , $ group , ExecutionContextInterface $ context )
648
648
{
649
- try {
650
- $ context ->setGroup ($ group );
651
-
652
- foreach ($ metadata ->findConstraints ($ group ) as $ constraint ) {
653
- // Prevent duplicate validation of constraints, in the case
654
- // that constraints belong to multiple validated groups
655
- if (null !== $ objectHash ) {
656
- $ constraintHash = spl_object_hash ($ constraint );
649
+ $ context ->setGroup ($ group );
657
650
658
- if ($ metadata instanceof ClassMetadataInterface) {
659
- if ($ context ->isClassConstraintValidated ($ objectHash , $ constraintHash )) {
660
- continue ;
661
- }
651
+ foreach ($ metadata ->findConstraints ($ group ) as $ constraint ) {
652
+ // Prevent duplicate validation of constraints, in the case
653
+ // that constraints belong to multiple validated groups
654
+ if (null !== $ objectHash ) {
655
+ $ constraintHash = spl_object_hash ($ constraint );
662
656
663
- $ context ->markClassConstraintAsValidated ($ objectHash , $ constraintHash );
664
- } elseif ($ metadata instanceof PropertyMetadataInterface) {
665
- $ propertyName = $ metadata ->getPropertyName ();
657
+ if ($ metadata instanceof ClassMetadataInterface) {
658
+ if ($ context ->isClassConstraintValidated ($ objectHash , $ constraintHash )) {
659
+ continue ;
660
+ }
666
661
667
- if ( $ context ->isPropertyConstraintValidated ($ objectHash , $ propertyName , $ constraintHash )) {
668
- continue ;
669
- }
662
+ $ context ->markClassConstraintAsValidated ($ objectHash , $ constraintHash );
663
+ } elseif ( $ metadata instanceof PropertyMetadataInterface) {
664
+ $ propertyName = $ metadata -> getPropertyName ();
670
665
671
- $ context ->markPropertyConstraintAsValidated ($ objectHash , $ propertyName , $ constraintHash );
666
+ if ($ context ->isPropertyConstraintValidated ($ objectHash , $ propertyName , $ constraintHash )) {
667
+ continue ;
672
668
}
673
- }
674
669
675
- $ validator = $ this ->validatorFactory ->getInstance ($ constraint );
676
- $ validator ->initialize ($ context );
677
- $ validator ->validate ($ value , $ constraint );
670
+ $ context ->markPropertyConstraintAsValidated ($ objectHash , $ propertyName , $ constraintHash );
671
+ }
678
672
}
679
673
680
- $ context ->setGroup (null );
681
- } catch (\Exception $ e ) {
682
- // Should be put into a finally block once we switch to PHP 5.5
683
- $ context ->setGroup (null );
684
-
685
- throw $ e ;
674
+ $ validator = $ this ->validatorFactory ->getInstance ($ constraint );
675
+ $ validator ->initialize ($ context );
676
+ $ validator ->validate ($ value , $ constraint );
686
677
}
687
678
}
688
679
0 commit comments