Skip to content

Commit

Permalink
Validator::validateFloat() accepts value that is already float (#262)
Browse files Browse the repository at this point in the history
Co-authored-by: David Grudl <david@grudl.com>
  • Loading branch information
Ciki and dg committed Jan 9, 2021
1 parent 63c2047 commit fcf446d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Forms/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,10 @@ public static function validateInteger(Control $control): bool
*/
public static function validateFloat(Control $control): bool
{
$value = str_replace([' ', ','], ['', '.'], $control->getValue());
$value = $control->getValue();
if (is_string($value)) {
$value = str_replace([' ', ','], ['', '.'], $value);
}
if (Validators::isNumeric($value)) {
$control->setValue((float) $value);
return true;
Expand Down

0 comments on commit fcf446d

Please sign in to comment.