mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
"Fixes #4001, 'money' validation uses invalid regular expression syntax"
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6605 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
1db7d00793
commit
e65f44bed2
2 changed files with 29 additions and 2 deletions
|
@ -577,10 +577,10 @@ class Validation extends Object {
|
||||||
$_this->check = $check;
|
$_this->check = $check;
|
||||||
switch ($symbolPosition) {
|
switch ($symbolPosition) {
|
||||||
case 'left':
|
case 'left':
|
||||||
$_this->regex = '/^(?!\\u00a2)\\p{Sc}?(?!0,?\\d)(?:\\d{1,3}(?:([, .])\\d{3})?(?:\\1\\d{3})*|(?:\\d+))((?!\\1)[,.]\\d{2})?$/';
|
$_this->regex = '/^(?!\x{00a2})\p{Sc}?(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?$/u';
|
||||||
break;
|
break;
|
||||||
case 'right':
|
case 'right':
|
||||||
$_this->regex = '/^(?!0,?\\d)(?:\\d{1,3}(?:([, .])\\d{3})?(?:\\1\\d{3})*|(?:\\d+))((?!\\1)[,.]\\d{2})?(?<!\\u00a2)\\p{Sc}?$/';
|
$_this->regex = '/^(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?(?<!\x{00a2})\p{Sc}?$/u';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $_this->_check();
|
return $_this->_check();
|
||||||
|
|
|
@ -1282,6 +1282,33 @@ class ValidationTestCase extends UnitTestCase {
|
||||||
$this->assertFalse(Validation::extension(array('noextension', 'extension.JPG', 'extension.gif', 'extension.png')));
|
$this->assertFalse(Validation::extension(array('noextension', 'extension.JPG', 'extension.gif', 'extension.png')));
|
||||||
$this->assertFalse(Validation::extension(array('extension.pdf', 'extension.JPG', 'extension.gif', 'extension.png')));
|
$this->assertFalse(Validation::extension(array('extension.pdf', 'extension.JPG', 'extension.gif', 'extension.png')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testMoney() {
|
||||||
|
$this->assertTrue(Validation::money('$100'));
|
||||||
|
$this->assertTrue(Validation::money('$100.11'));
|
||||||
|
$this->assertTrue(Validation::money('$100.112'));
|
||||||
|
$this->assertFalse(Validation::money('$100.1'));
|
||||||
|
$this->assertFalse(Validation::money('$100.1111'));
|
||||||
|
$this->assertFalse(Validation::money('text'));
|
||||||
|
|
||||||
|
$this->assertTrue(Validation::money('100', 'right'));
|
||||||
|
$this->assertTrue(Validation::money('100.11$', 'right'));
|
||||||
|
$this->assertTrue(Validation::money('100.112$', 'right'));
|
||||||
|
$this->assertFalse(Validation::money('100.1$', 'right'));
|
||||||
|
$this->assertFalse(Validation::money('100.1111$', 'right'));
|
||||||
|
|
||||||
|
$this->assertTrue(Validation::money('€100'));
|
||||||
|
$this->assertTrue(Validation::money('€100.11'));
|
||||||
|
$this->assertTrue(Validation::money('€100.112'));
|
||||||
|
$this->assertFalse(Validation::money('€100.1'));
|
||||||
|
$this->assertFalse(Validation::money('€100.1111'));
|
||||||
|
|
||||||
|
$this->assertTrue(Validation::money('100', 'right'));
|
||||||
|
$this->assertTrue(Validation::money('100.11€', 'right'));
|
||||||
|
$this->assertTrue(Validation::money('100.112€', 'right'));
|
||||||
|
$this->assertFalse(Validation::money('100.1€', 'right'));
|
||||||
|
$this->assertFalse(Validation::money('100.1111€', 'right'));
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
function TestFile() {
|
function TestFile() {
|
||||||
$this->assertTrue(Validation::file(WWW_ROOT . 'img' . DS . 'cake.icon.gif'));
|
$this->assertTrue(Validation::file(WWW_ROOT . 'img' . DS . 'cake.icon.gif'));
|
||||||
|
|
Loading…
Add table
Reference in a new issue