概要
cake2.3系の開発をしているのですが、フレームワーク由来の不具合があり、cakephpのvalidationのメソッドを上書き修正したいです。
環境
php5.3
cakephp2.3.10
該当箇所
- cakephp2.3.10
cakephp/lib/Cake/Utility/Validation.php
php
1 public static function cc($check, $type = 'fast', $deep = false, $regex = null) { 2 if (is_array($check)) { 3 extract(self::_defaults($check)); 4 } 5 6 $check = str_replace(array('-', ' '), '', $check); 7 if (mb_strlen($check) < 13) { 8 return false; 9 } 10 11 if ($regex !== null) { 12 if (self::_check($check, $regex)) { 13 return self::luhn($check, $deep); 14 } 15 } 16 $cards = array( 17 'all' => array( 18 'amex' => '/^3[4|7]\d{13}$/', 19 'bankcard' => '/^56(10\d\d|022[1-5])\d{10}$/', 20 'diners' => '/^(?:3(0[0-5]|[68]\d)\d{11})|(?:5[1-5]\d{14})$/', 21 'disc' => '/^(?:6011|650\d)\d{12}$/', 22 'electron' => '/^(?:417500|4917\d{2}|4913\d{2})\d{10}$/', 23 'enroute' => '/^2(?:014|149)\d{11}$/', 24 'jcb' => '/^(3\d{4}|2100|1800)\d{11}$/', 25 'maestro' => '/^(?:5020|6\d{3})\d{12}$/', 26 'mc' => '/^5[1-5]\d{14}$/', 27 'solo' => '/^(6334[5-9][0-9]|6767[0-9]{2})\d{10}(\d{2,3})?$/', 28 'switch' => '/^(?:49(03(0[2-9]|3[5-9])|11(0[1-2]|7[4-9]|8[1-2])|36[0-9]{2})\d{10}(\d{2,3})?)|(?:564182\d{10}(\d{2,3})?)|(6(3(33[0-4][0-9])|759[0-9]{2})\d{10}(\d{2,3})?)$/', 29 'visa' => '/^4\d{12}(\d{3})?$/', 30 'voyager' => '/^8699[0-9]{11}$/' 31 ), 32 'fast' => '/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$/' 33 ); 34 35 if (is_array($type)) { 36 foreach ($type as $value) { 37 $regex = $cards['all'][strtolower($value)]; 38 39 if (self::_check($check, $regex)) { 40 return self::luhn($check, $deep); 41 } 42 } 43 } elseif ($type === 'all') { 44 foreach ($cards['all'] as $value) { 45 $regex = $value; 46 47 if (self::_check($check, $regex)) { 48 return self::luhn($check, $deep); 49 } 50 } 51 } else { 52 $regex = $cards['fast']; 53 54 if (self::_check($check, $regex)) { 55 return self::luhn($check, $deep); 56 } 57 } 58 return false; 59 }
修正内容
https://github.com/cakephp/cakephp/pull/11270/files
jcbカードのバリデーションエラーの修正を当てたいです。
php
1 $cards = array( 2 'jcb' => '/^(35\d{3}|2131|1800)\d{11}$/',
ご教示よろしくお願いいたします。