Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions library/Zend/I18n/Validator/Float.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public function isValid($value)

//We have seperators, and they are flipped. i.e. 2.000,000 for en-US
if ($groupSeparatorPosition && $decSeparatorPosition && $groupSeparatorPosition > $decSeparatorPosition) {
$this->error(self::NOT_FLOAT);
return false;
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moderndeveloperllc or add more conditional here to set if locale = 'en-US' then it return false ? //cc @DASPRiD

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return true I mean

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we don't add more conditionals there. I was giving an example of why we needed this code at all. If someone were to try and validate 2.000,000 for en-US, it would pass the conditional and return false for the function.


Expand Down Expand Up @@ -237,6 +238,7 @@ public function isValid($value)
return true;
}

$this->error(self::NOT_FLOAT);
return false;
}
}
11 changes: 11 additions & 0 deletions tests/ZendTest/I18n/Validator/FloatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,15 @@ public function testEqualsMessageTemplates()
$validator = $this->validator;
$this->assertAttributeEquals($validator->getOption('messageTemplates'), 'messageTemplates', $validator);
}

/**
* @group 6647
*/
public function testNotFloat()
{
$this->assertFalse($this->validator->isValid('2.000.000,00'));

$message = $this->validator->getMessages();
$this->assertContains('does not appear to be a float', $message['notFloat']);
}
}