mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix notBlank() to pass on -0.0
Copy the implementation from 3.x as it works with -0.0 already. Refs #10521
This commit is contained in:
parent
f08d96306b
commit
9007a7fe58
2 changed files with 7 additions and 8 deletions
|
@ -148,6 +148,10 @@ class ValidationTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testNotBlank() {
|
public function testNotBlank() {
|
||||||
|
$this->assertTrue(Validation::notBlank(0));
|
||||||
|
$this->assertTrue(Validation::notBlank(0.0));
|
||||||
|
$this->assertTrue(Validation::notBlank(-0));
|
||||||
|
$this->assertTrue(Validation::notBlank(-0.0));
|
||||||
$this->assertTrue(Validation::notBlank('abcdefg'));
|
$this->assertTrue(Validation::notBlank('abcdefg'));
|
||||||
$this->assertTrue(Validation::notBlank('fasdf '));
|
$this->assertTrue(Validation::notBlank('fasdf '));
|
||||||
$this->assertTrue(Validation::notBlank('fooo' . chr(243) . 'blabla'));
|
$this->assertTrue(Validation::notBlank('fooo' . chr(243) . 'blabla'));
|
||||||
|
|
|
@ -66,19 +66,14 @@ class Validation {
|
||||||
*
|
*
|
||||||
* Returns true if string contains something other than whitespace
|
* Returns true if string contains something other than whitespace
|
||||||
*
|
*
|
||||||
* $check can be passed as an array:
|
* @param string $check Value to check
|
||||||
* array('check' => 'valueToCheck');
|
|
||||||
*
|
|
||||||
* @param string|array $check Value to check
|
|
||||||
* @return bool Success
|
* @return bool Success
|
||||||
*/
|
*/
|
||||||
public static function notBlank($check) {
|
public static function notBlank($check) {
|
||||||
if (!is_scalar($check)) {
|
if (empty($check) && !is_bool($check) && !is_numeric($check)) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (empty($check) && (string)$check !== '0') {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return static::_check($check, '/[^\s]+/m');
|
return static::_check($check, '/[^\s]+/m');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue