From 2446a1763d75e8c26058caa7cbad1340fd698533 Mon Sep 17 00:00:00 2001 From: Raul Fraile Date: Fri, 7 Dec 2018 19:30:58 +0100 Subject: [PATCH] [Validator] Add support for UATP card validation --- src/Symfony/Component/Validator/CHANGELOG.md | 1 + .../Component/Validator/Constraints/CardSchemeValidator.php | 4 ++++ .../Validator/Tests/Constraints/CardSchemeValidatorTest.php | 2 ++ 3 files changed, 7 insertions(+) diff --git a/src/Symfony/Component/Validator/CHANGELOG.md b/src/Symfony/Component/Validator/CHANGELOG.md index e2dfc921e40b7..45e00e00a90cf 100644 --- a/src/Symfony/Component/Validator/CHANGELOG.md +++ b/src/Symfony/Component/Validator/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG ----- * added options `iban` and `ibanPropertyPath` to Bic constraint + * added UATP cards support to `CardSchemeValidator` 4.2.0 ----- diff --git a/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php b/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php index dae3412cd7178..0a3c06c1454bc 100644 --- a/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php @@ -78,6 +78,10 @@ class CardSchemeValidator extends ConstraintValidator '/^5[1-5][0-9]{14}$/', '/^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})$/', ), + // All UATP card numbers start with a 1 and have a length of 15 digits. + 'UATP' => array( + '/^1[0-9]{14}$/', + ), // All Visa card numbers start with a 4 and have a length of 13, 16, or 19 digits. 'VISA' => array( '/^4([0-9]{12}|[0-9]{15}|[0-9]{18})$/', diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php index b0280713d5285..fccee9e0abc1a 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php @@ -103,6 +103,7 @@ public function getValidNumbers() array('MASTERCARD', '2699999999999999'), array('MASTERCARD', '2709999999999999'), array('MASTERCARD', '2720995105105100'), + array('UATP', '110165309696173'), array('VISA', '4111111111111111'), array('VISA', '4012888888881881'), array('VISA', '4222222222222'), @@ -133,6 +134,7 @@ public function getInvalidNumbers() array('DISCOVER', '1117', CardScheme::INVALID_FORMAT_ERROR), // only last 4 digits array('MASTERCARD', '2721001234567890', CardScheme::INVALID_FORMAT_ERROR), // Not assigned yet array('MASTERCARD', '2220991234567890', CardScheme::INVALID_FORMAT_ERROR), // Not assigned yet + array('UATP', '11016530969617', CardScheme::INVALID_FORMAT_ERROR), // invalid length ); } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy