api/symfony/Component/Validator/Constraints/CardSchemeValidator.yaml

74 lines
4.2 KiB
YAML
Raw Normal View History

2024-09-26 09:03:21 +00:00
name: CardSchemeValidator
class_comment: '# * Validates that a card number belongs to a specified scheme.
# *
# * @author Tim Nagel <t.nagel@infinite.net.au>
# * @author Bernhard Schussek <bschussek@gmail.com>
# *
# * @see https://en.wikipedia.org/wiki/Payment_card_number
# * @see https://www.regular-expressions.info/creditcard.html'
dependencies:
- name: Constraint
type: class
source: Symfony\Component\Validator\Constraint
- name: ConstraintValidator
type: class
source: Symfony\Component\Validator\ConstraintValidator
- name: UnexpectedTypeException
type: class
source: Symfony\Component\Validator\Exception\UnexpectedTypeException
properties: []
methods:
- name: validate
visibility: public
parameters:
- name: value
- name: constraint
comment: "# * Validates that a card number belongs to a specified scheme.\n# *\n\
# * @author Tim Nagel <t.nagel@infinite.net.au>\n# * @author Bernhard Schussek\
\ <bschussek@gmail.com>\n# *\n# * @see https://en.wikipedia.org/wiki/Payment_card_number\n\
# * @see https://www.regular-expressions.info/creditcard.html\n# */\n# class CardSchemeValidator\
\ extends ConstraintValidator\n# {\n# protected array $schemes = [\n# // American\
\ Express card numbers start with 34 or 37 and have 15 digits.\n# CardScheme::AMEX\
\ => [\n# '/^3[47][0-9]{13}$/',\n# ],\n# // China UnionPay cards start with 62\
\ and have between 16 and 19 digits.\n# // Please note that these cards do not\
\ follow Luhn Algorithm as a checksum.\n# CardScheme::CHINA_UNIONPAY => [\n# '/^62[0-9]{14,17}$/',\n\
# ],\n# // Diners Club card numbers begin with 300 through 305, 36 or 38. All\
\ have 14 digits.\n# // There are Diners Club cards that begin with 5 and have\
\ 16 digits.\n# // These are a joint venture between Diners Club and MasterCard,\
\ and should be processed like a MasterCard.\n# CardScheme::DINERS => [\n# '/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/',\n\
# ],\n# // Discover card numbers begin with 6011, 622126 through 622925, 644 through\
\ 649 or 65.\n# // All have 16 digits.\n# CardScheme::DISCOVER => [\n# '/^6011[0-9]{12}$/',\n\
# '/^64[4-9][0-9]{13}$/',\n# '/^65[0-9]{14}$/',\n# '/^622(12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|91[0-9]|92[0-5])[0-9]{10}$/',\n\
# ],\n# // InstaPayment cards begin with 637 through 639 and have 16 digits.\n\
# CardScheme::INSTAPAYMENT => [\n# '/^63[7-9][0-9]{13}$/',\n# ],\n# // JCB cards\
\ beginning with 2131 or 1800 have 15 digits.\n# // JCB cards beginning with 35\
\ have 16 digits.\n# CardScheme::JCB => [\n# '/^(?:2131|1800|35[0-9]{3})[0-9]{11}$/',\n\
# ],\n# // Laser cards begin with either 6304, 6706, 6709 or 6771 and have between\
\ 16 and 19 digits.\n# CardScheme::LASER => [\n# '/^(6304|670[69]|6771)[0-9]{12,15}$/',\n\
# ],\n# // Maestro international cards begin with 675900..675999 and have between\
\ 12 and 19 digits.\n# // Maestro UK cards begin with either 500000..509999 or\
\ 560000..699999 and have between 12 and 19 digits.\n# CardScheme::MAESTRO =>\
\ [\n# '/^(6759[0-9]{2})[0-9]{6,13}$/',\n# '/^(50[0-9]{4})[0-9]{6,13}$/',\n# '/^5[6-9][0-9]{10,17}$/',\n\
# '/^6[0-9]{11,18}$/',\n# ],\n# // All MasterCard numbers start with the numbers\
\ 51 through 55. All have 16 digits.\n# // October 2016 MasterCard numbers can\
\ also start with 222100 through 272099.\n# CardScheme::MASTERCARD => [\n# '/^5[1-5][0-9]{14}$/',\n\
# '/^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})$/',\n\
# ],\n# // Payment system MIR numbers start with 220, then 1 digit from 0 to 4,\
\ then between 12 and 15 digits\n# CardScheme::MIR => [\n# '/^220[0-4][0-9]{12,15}$/',\n\
# ],\n# // All UATP card numbers start with a 1 and have a length of 15 digits.\n\
# CardScheme::UATP => [\n# '/^1[0-9]{14}$/',\n# ],\n# // All Visa card numbers\
\ start with a 4 and have a length of 13, 16, or 19 digits.\n# CardScheme::VISA\
\ => [\n# '/^4([0-9]{12}|[0-9]{15}|[0-9]{18})$/',\n# ],\n# ];\n# \n# /**\n# *\
\ Validates a creditcard belongs to a specified scheme."
traits:
- Symfony\Component\Validator\Constraint
- Symfony\Component\Validator\ConstraintValidator
- Symfony\Component\Validator\Exception\UnexpectedTypeException
interfaces: []