Skip to content

Commit a4ccc71

Browse files
raulfrailefabpot
authored andcommitted
[Validator] Add support for UATP card validation
1 parent efbf120 commit a4ccc71

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

CHANGELOG.md

Lines 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
-----

Constraints/CardSchemeValidator.php

Lines 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})$/',

Tests/Constraints/CardSchemeValidatorTest.php

Lines 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)