laminas / laminas-i18n

Provide translations for your application, and filter and validate internationalized values
https://docs.laminas.dev/laminas-i18n/
BSD 3-Clause "New" or "Revised" License
50 stars 29 forks source link

IsFloat validator should return a standard error message for empty strings #110

Closed froschdesign closed 12 months ago

froschdesign commented 12 months ago
Q A
Documentation no
Bugfix yes
BC Break no
New Feature no
RFC no
QA no

Description

The following code throws an AssertionError:

$validator = new Laminas\I18n\Validator\IsFloat();
var_dump($validator->isValid(''));
Fatal error: Uncaught AssertionError: assert($lastStringGroup !== '') in /src/Validator/IsFloat.php:242

https://github.com/laminas/laminas-i18n/blob/4f23433e415b14c4d66a7d7d1983c5890ac9ed2a/src/Validator/IsFloat.php#L233-L242

These lines were introduced with #104: https://github.com/laminas/laminas-i18n/pull/104/commits/5062ef1b6e725eb2a05c56759ac241c1ef776cf2

In previous versions this was not a problem:

$validator = new Laminas\I18n\Validator\IsFloat();
var_dump($validator->isValid('')); // false
var_dump($validator->getMessages()); ['notFloat' => 'The input does not appear to be a float']
gsteel commented 12 months ago

@froschdesign Look good to you? I can't request your review because you opened the patch!

froschdesign commented 12 months ago

@gsteel Thank you for your help! 👍🏻