Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7dc1521

Browse filesBrowse files
committed
feature #29504 [Validator] Add support for UATP card validation (raulfraile)
This PR was squashed before being merged into the 4.3-dev branch (closes #29504). Discussion ---------- [Validator] Add support for UATP card validation | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT [UATP](https://en.wikipedia.org/wiki/Universal_Air_Travel_Plan) (Universal Air Travel Plan) is the airline owned payment network accepted by thousands of merchants for rail, air, hotel and travel agency payments. This PR adds support for UATP cards so they can be validated using the Symfony Validator component. According to https://en.wikipedia.org/wiki/Payment_card_number, all UATP cards start with `1`, have a length of 15 digits and follow the [Luhn algorithm](https://en.wikipedia.org/wiki/Luhn_algorithm). Test card numbers can be generated from https://www.myfakeinfo.com/creditcard/uatp-debit-card.php Commits ------- 2446a17 [Validator] Add support for UATP card validation
2 parents 58b29d6 + 2446a17 commit 7dc1521
Copy full SHA for 7dc1521

File tree

3 files changed

+7
-0
lines changed
Filter options

3 files changed

+7
-0
lines changed

‎src/Symfony/Component/Validator/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
-----
66

77
* added options `iban` and `ibanPropertyPath` to Bic constraint
8+
* added UATP cards support to `CardSchemeValidator`
89

910
4.2.0
1011
-----

‎src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ class CardSchemeValidator extends ConstraintValidator
7878
'/^5[1-5][0-9]{14}$/',
7979
'/^2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12})$/',
8080
),
81+
// All UATP card numbers start with a 1 and have a length of 15 digits.
82+
'UATP' => array(
83+
'/^1[0-9]{14}$/',
84+
),
8185
// All Visa card numbers start with a 4 and have a length of 13, 16, or 19 digits.
8286
'VISA' => array(
8387
'/^4([0-9]{12}|[0-9]{15}|[0-9]{18})$/',

‎src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public function getValidNumbers()
103103
array('MASTERCARD', '2699999999999999'),
104104
array('MASTERCARD', '2709999999999999'),
105105
array('MASTERCARD', '2720995105105100'),
106+
array('UATP', '110165309696173'),
106107
array('VISA', '4111111111111111'),
107108
array('VISA', '4012888888881881'),
108109
array('VISA', '4222222222222'),
@@ -133,6 +134,7 @@ public function getInvalidNumbers()
133134
array('DISCOVER', '1117', CardScheme::INVALID_FORMAT_ERROR), // only last 4 digits
134135
array('MASTERCARD', '2721001234567890', CardScheme::INVALID_FORMAT_ERROR), // Not assigned yet
135136
array('MASTERCARD', '2220991234567890', CardScheme::INVALID_FORMAT_ERROR), // Not assigned yet
137+
array('UATP', '11016530969617', CardScheme::INVALID_FORMAT_ERROR), // invalid length
136138
);
137139
}
138140
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.