Adding mb_ functions to Validation methods.

This commit is contained in:
mark_story 2009-09-29 00:10:34 -04:00
parent 0d3ef03b9f
commit 2c144a9d0d

View file

@ -25,7 +25,9 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
if (!class_exists('Multibyte')) {
App::import('Core', 'Multibyte');
}
/**
* Offers different validation methods.
*
@ -183,7 +185,7 @@ class Validation extends Object {
* @access public
*/
function between($check, $min, $max) {
$length = strlen($check);
$length = mb_strlen($check);
return ($length >= $min && $length <= $max);
}
@ -238,7 +240,7 @@ class Validation extends Object {
}
$_this->check = str_replace(array('-', ' '), '', $_this->check);
if (strlen($_this->check) < 13) {
if (mb_strlen($_this->check) < 13) {
return false;
}
@ -247,7 +249,9 @@ class Validation extends Object {
return $_this->_luhn();
}
}
$cards = array('all' => array('amex' => '/^3[4|7]\\d{13}$/',
$cards = array(
'all' => array(
'amex' => '/^3[4|7]\\d{13}$/',
'bankcard' => '/^56(10\\d\\d|022[1-5])\\d{10}$/',
'diners' => '/^(?:3(0[0-5]|[68]\\d)\\d{11})|(?:5[1-5]\\d{14})$/',
'disc' => '/^(?:6011|650\\d)\\d{12}$/',
@ -259,8 +263,10 @@ class Validation extends Object {
'solo' => '/^(6334[5-9][0-9]|6767[0-9]{2})\\d{10}(\\d{2,3})?$/',
'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})?)$/',
'visa' => '/^4\\d{12}(\\d{3})?$/',
'voyager' => '/^8699[0-9]{11}$/'),
'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})$/');
'voyager' => '/^8699[0-9]{11}$/'
),
'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})$/'
);
if (is_array($_this->type)) {
foreach ($_this->type as $value) {
@ -588,7 +594,7 @@ class Validation extends Object {
* @access public
*/
function minLength($check, $min) {
$length = strlen($check);
$length = mb_strlen($check);
return ($length >= $min);
}
@ -601,7 +607,7 @@ class Validation extends Object {
* @access public
*/
function maxLength($check, $max) {
$length = strlen($check);
$length = mb_strlen($check);
return ($length <= $max);
}
@ -890,7 +896,7 @@ class Validation extends Object {
$_this->regex = $regex;
}
if (isset($country)) {
$_this->country = strtolower($country);
$_this->country = mb_strtolower($country);
}
if (isset($deep)) {
$_this->deep = $deep;