mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Merge branch '2.0' of git://github.com/predominant/cakephp1x into 2.0
This commit is contained in:
commit
e0b4e3dd96
1 changed files with 13 additions and 4 deletions
|
@ -430,8 +430,16 @@ class Validation {
|
|||
* @param string $ipVersion The IP Protocol version to validate against
|
||||
* @return boolean Success
|
||||
*/
|
||||
public function ip($check, $type = 'IPv4') {
|
||||
return (boolean) filter_var($check, FILTER_VALIDATE_IP);
|
||||
public function ip($check, $type = 'both') {
|
||||
$type = strtolower($type);
|
||||
$flags = array();
|
||||
if ($type === 'ipv4' || $type === 'both') {
|
||||
$flags[] = FILTER_FLAG_IPV4;
|
||||
}
|
||||
if ($type === 'ipv6' || $type === 'both') {
|
||||
$flags[] = FILTER_FLAG_IPV6;
|
||||
}
|
||||
return (boolean)filter_var($check, FILTER_VALIDATE_IP, array('flags' => $flags));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -464,10 +472,11 @@ class Validation {
|
|||
* @return boolean Success
|
||||
*/
|
||||
public static function money($check, $symbolPosition = 'left') {
|
||||
$money = '(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?';
|
||||
if ($symbolPosition == 'right') {
|
||||
$regex = '/^(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?(?<!\x{00a2})\p{Sc}?$/u';
|
||||
$regex = '/^' . $money . '(?<!\x{00a2})\p{Sc}?$/u';
|
||||
} else {
|
||||
$regex = '/^(?!\x{00a2})\p{Sc}?(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?$/u';
|
||||
$regex = '/^(?!\x{00a2})\p{Sc}?' . $money . '$/u';
|
||||
}
|
||||
return self::_check($check, $regex);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue