Skip to content

Commit

Permalink
Merge pull request #80 from iricketson/issue/75
Browse files Browse the repository at this point in the history
Revert strict decimal comparison
  • Loading branch information
j0k3r authored Jun 25, 2020
2 parents ebcfdbb + 3c81a57 commit 49f2549
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Doctrine/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public static function isValidType($var, $type)
case 'float':
case 'double':
case 'decimal':
return (string) $var === (string) (float) $var;
return (string) $var == (string) (float) $var;
case 'integer':
return (string) $var === (string)round((float) $var);
case 'string':
Expand Down
7 changes: 7 additions & 0 deletions tests/ValidatorTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ public function testIsValidType()
$this->assertFalse(Doctrine_Validator::isValidType($var, 'array'));
$this->assertFalse(Doctrine_Validator::isValidType($var, 'object'));

$var = '123.00';
$this->assertTrue(Doctrine_Validator::isValidType($var, 'string'));
$this->assertFalse(Doctrine_Validator::isValidType($var, 'integer'));
$this->assertTrue(Doctrine_Validator::isValidType($var, 'float'));
$this->assertFalse(Doctrine_Validator::isValidType($var, 'array'));
$this->assertFalse(Doctrine_Validator::isValidType($var, 'object'));

$var = '';
$this->assertTrue(Doctrine_Validator::isValidType($var, 'string'));
$this->assertFalse(Doctrine_Validator::isValidType($var, 'integer'));
Expand Down

0 comments on commit 49f2549

Please sign in to comment.