Mercurial > hg > cmmr2012-drupal-site
comparison vendor/symfony/validator/Constraints/IbanValidator.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children | 12f9dff5fda9 |
comparison
equal
deleted
inserted
replaced
3:307d7a7fd348 | 4:a9cd425dd02b |
---|---|
33 * a BBAN (Basic Bank Account Number) which has a fixed length per country and, | 33 * a BBAN (Basic Bank Account Number) which has a fixed length per country and, |
34 * included within it, a bank identifier with a fixed position and a fixed length per country | 34 * included within it, a bank identifier with a fixed position and a fixed length per country |
35 * | 35 * |
36 * @see https://www.swift.com/sites/default/files/resources/iban_registry.pdf | 36 * @see https://www.swift.com/sites/default/files/resources/iban_registry.pdf |
37 */ | 37 */ |
38 private static $formats = array( | 38 private static $formats = [ |
39 'AD' => 'AD\d{2}\d{4}\d{4}[\dA-Z]{12}', // Andorra | 39 'AD' => 'AD\d{2}\d{4}\d{4}[\dA-Z]{12}', // Andorra |
40 'AE' => 'AE\d{2}\d{3}\d{16}', // United Arab Emirates | 40 'AE' => 'AE\d{2}\d{3}\d{16}', // United Arab Emirates |
41 'AL' => 'AL\d{2}\d{8}[\dA-Z]{16}', // Albania | 41 'AL' => 'AL\d{2}\d{8}[\dA-Z]{16}', // Albania |
42 'AO' => 'AO\d{2}\d{21}', // Angola | 42 'AO' => 'AO\d{2}\d{21}', // Angola |
43 'AT' => 'AT\d{2}\d{5}\d{11}', // Austria | 43 'AT' => 'AT\d{2}\d{5}\d{11}', // Austria |
127 'TF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // French Southern Territories | 127 'TF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // French Southern Territories |
128 'TL' => 'TL\d{2}\d{3}\d{14}\d{2}', // Timor-Leste | 128 'TL' => 'TL\d{2}\d{3}\d{14}\d{2}', // Timor-Leste |
129 'TN' => 'TN59\d{2}\d{3}\d{13}\d{2}', // Tunisia | 129 'TN' => 'TN59\d{2}\d{3}\d{13}\d{2}', // Tunisia |
130 'TR' => 'TR\d{2}\d{5}[\dA-Z]{1}[\dA-Z]{16}', // Turkey | 130 'TR' => 'TR\d{2}\d{5}[\dA-Z]{1}[\dA-Z]{16}', // Turkey |
131 'UA' => 'UA\d{2}\d{6}[\dA-Z]{19}', // Ukraine | 131 'UA' => 'UA\d{2}\d{6}[\dA-Z]{19}', // Ukraine |
132 'VA' => 'VA\d{2}\d{3}\d{15}', // Vatican City State | |
132 'VG' => 'VG\d{2}[A-Z]{4}\d{16}', // Virgin Islands, British | 133 'VG' => 'VG\d{2}[A-Z]{4}\d{16}', // Virgin Islands, British |
133 'WF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Wallis and Futuna Islands | 134 'WF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Wallis and Futuna Islands |
134 'XK' => 'XK\d{2}\d{4}\d{10}\d{2}', // Republic of Kosovo | 135 'XK' => 'XK\d{2}\d{4}\d{10}\d{2}', // Republic of Kosovo |
135 'YT' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Mayotte | 136 'YT' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // Mayotte |
136 ); | 137 ]; |
137 | 138 |
138 /** | 139 /** |
139 * {@inheritdoc} | 140 * {@inheritdoc} |
140 */ | 141 */ |
141 public function validate($value, Constraint $constraint) | 142 public function validate($value, Constraint $constraint) |
146 | 147 |
147 if (null === $value || '' === $value) { | 148 if (null === $value || '' === $value) { |
148 return; | 149 return; |
149 } | 150 } |
150 | 151 |
151 if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { | 152 if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { |
152 throw new UnexpectedTypeException($value, 'string'); | 153 throw new UnexpectedTypeException($value, 'string'); |
153 } | 154 } |
154 | 155 |
155 $value = (string) $value; | 156 $value = (string) $value; |
156 | 157 |
229 $bigInt = ''; | 230 $bigInt = ''; |
230 | 231 |
231 foreach ($chars as $char) { | 232 foreach ($chars as $char) { |
232 // Convert uppercase characters to ordinals, starting with 10 for "A" | 233 // Convert uppercase characters to ordinals, starting with 10 for "A" |
233 if (ctype_upper($char)) { | 234 if (ctype_upper($char)) { |
234 $bigInt .= (ord($char) - 55); | 235 $bigInt .= (\ord($char) - 55); |
235 | 236 |
236 continue; | 237 continue; |
237 } | 238 } |
238 | 239 |
239 // Simply append digits | 240 // Simply append digits |