diff --git a/src/Validator/IsFloat.php b/src/Validator/IsFloat.php index 0c29774a..07556ec2 100644 --- a/src/Validator/IsFloat.php +++ b/src/Validator/IsFloat.php @@ -235,7 +235,9 @@ public function isValid($value) // No strrpos() in wrappers yet. ICU 4.x doesn't have grouping size for // everything. ICU 52 has 3 for ALL locales. $groupSize = $formatter->getAttribute(NumberFormatter::GROUPING_SIZE) ?: 3; - $lastStringGroup = $this->wrapper->substr($value, -$groupSize); + $lastStringGroup = $this->wrapper->strlen($value) > $groupSize ? + $this->wrapper->substr($value, -$groupSize) : + $value; if ((preg_match($lnumSearch, $unGroupedValue) || preg_match($dnumSearch, $unGroupedValue) diff --git a/test/Validator/IsFloatTest.php b/test/Validator/IsFloatTest.php index 0073f6e1..e7a84ae1 100644 --- a/test/Validator/IsFloatTest.php +++ b/test/Validator/IsFloatTest.php @@ -73,7 +73,7 @@ public function floatAndIntegerProvider() $trueArray = []; $testingLocales = ['ar', 'bn', 'de', 'dz', 'en', 'fr-CH', 'ja', 'ks', 'ml-IN', 'mr', 'my', 'ps', 'ru']; $testingExamples = [1000, -2000, +398.00, 0.04, -0.5, .6, -.70, 8E10, -9.3456E-2, 10.23E6, - 123.1234567890987654321]; + 123.1234567890987654321, 1, 13, -3]; //Loop locales and examples for a more thorough set of "true" test data foreach ($testingLocales as $locale) {