Skip to content

Commit 3f8e218

Browse files
committed
bug symfony#16806 [Validator] BicValidator - fixed raising violations to a maximum of one (mvhirsch)
This PR was merged into the 2.8 branch. Discussion ---------- [Validator] BicValidator - fixed raising violations to a maximum of one | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | none I just found a bug while using the constraint. For example my value "a" will raise three violations at one time. I just expected to get a maximum number of one. This PR will fix that behavior. I do not know how I can easily add Unit-Tests for that, can someone please help me? Commits ------- 7860bb4 [Validator] fixed raising violations to a maximum of one
2 parents d4fff99 + 7860bb4 commit 3f8e218

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Symfony/Component/Validator/Constraints/BicValidator.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public function validate($value, Constraint $constraint)
3838
->setParameter('{{ value }}', $this->formatValue($value))
3939
->setCode(Bic::INVALID_LENGTH_ERROR)
4040
->addViolation();
41+
42+
return;
4143
}
4244

4345
// must contain alphanumeric values only
@@ -46,6 +48,8 @@ public function validate($value, Constraint $constraint)
4648
->setParameter('{{ value }}', $this->formatValue($value))
4749
->setCode(Bic::INVALID_CHARACTERS_ERROR)
4850
->addViolation();
51+
52+
return;
4953
}
5054

5155
// first 4 letters must be alphabetic (bank code)
@@ -54,6 +58,8 @@ public function validate($value, Constraint $constraint)
5458
->setParameter('{{ value }}', $this->formatValue($value))
5559
->setCode(Bic::INVALID_BANK_CODE_ERROR)
5660
->addViolation();
61+
62+
return;
5763
}
5864

5965
// next 2 letters must be alphabetic (country code)
@@ -62,6 +68,8 @@ public function validate($value, Constraint $constraint)
6268
->setParameter('{{ value }}', $this->formatValue($value))
6369
->setCode(Bic::INVALID_COUNTRY_CODE_ERROR)
6470
->addViolation();
71+
72+
return;
6573
}
6674

6775
// should contain uppercase characters only
@@ -70,6 +78,8 @@ public function validate($value, Constraint $constraint)
7078
->setParameter('{{ value }}', $this->formatValue($value))
7179
->setCode(Bic::INVALID_CASE_ERROR)
7280
->addViolation();
81+
82+
return;
7383
}
7484
}
7585
}

0 commit comments

Comments
 (0)