diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index 2af075603..ee0de0b18 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -1958,29 +1958,38 @@ class ValidationTest extends CakeTestCase { * @return void */ public function testMoney() { + $this->assertTrue(Validation::money('100')); + $this->assertTrue(Validation::money('100.11')); + $this->assertTrue(Validation::money('100.112')); + $this->assertTrue(Validation::money('100.1')); + $this->assertTrue(Validation::money('100.111,1')); + $this->assertTrue(Validation::money('100.111,11')); + $this->assertFalse(Validation::money('100.111,111')); + $this->assertFalse(Validation::money('text')); + $this->assertTrue(Validation::money('$100')); $this->assertTrue(Validation::money('$100.11')); $this->assertTrue(Validation::money('$100.112')); - $this->assertFalse(Validation::money('$100.1')); + $this->assertTrue(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->assertTrue(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->assertTrue(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->assertTrue(Validation::money('100.1€', 'right')); $this->assertFalse(Validation::money('100.1111€', 'right')); } diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 735f7d94a..e83d45fdf 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -528,7 +528,7 @@ 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{1})?'; + $money = '(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{1,2})?'; if ($symbolPosition === 'right') { $regex = '/^' . $money . '(?