-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] added BIC (SWIFT-BIC) validation constraint #15519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
2fd8573
99bc9f1
a2b612e
ec839e7
398988d
be41875
f278cbb
71e11d7
fc432e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ public function validate($value, Constraint $constraint) | |
|
||
$canonicalize = str_replace(' ', '', $value); | ||
|
||
// the bic must have either 8 or 11 characters | ||
// the bic must be either 8 or 11 characters long | ||
if (8 !== strlen($canonicalize) && 11 !== strlen($canonicalize)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about
? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Triiistan I suspect looping over an array is not faster than performing a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stof i think @Triiistan is talking about better readability There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was trying to save 1 call from
and
and the latter was used a bit more. With the first style, we can write
to avoid the duplication. [Updated: I inverted both styles] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. However, my concern may not be very pragmatic, so go with the version most readable to your eyes 😃 |
||
$this->context->buildViolation($constraint->message) | ||
->setParameter('{{ value }}', $this->formatValue($value)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this condition correct?Excuse me! The code is correct. I didn't understand the above comment correctly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would say yes, if it is not 8 AND not 11 characters long, then buildViolation