Permalink
Browse files

Deprecate notEmpty in favor of notBlank.

  • Loading branch information...
dereuromark committed May 17, 2015
1 parent ca76839 commit 866242643f5ea4da2a567a618ebf7a5a8005b7ad
Showing with 32 additions and 19 deletions.
  1. +17 −17 lib/Cake/Test/Case/Utility/ValidationTest.php
  2. +15 −2 lib/Cake/Utility/Validation.php
@@ -129,15 +129,15 @@ public function tearDown() {
* @return void
*/
public function testNotEmpty() {
$this->assertTrue(Validation::notEmpty('abcdefg'));
$this->assertTrue(Validation::notEmpty('fasdf '));
$this->assertTrue(Validation::notEmpty('fooo' . chr(243) . 'blabla'));
$this->assertTrue(Validation::notEmpty('abçďĕʑʘπй'));
$this->assertTrue(Validation::notEmpty('José'));
$this->assertTrue(Validation::notEmpty('é'));
$this->assertTrue(Validation::notEmpty('π'));
$this->assertFalse(Validation::notEmpty("\t "));
$this->assertFalse(Validation::notEmpty(""));
$this->assertTrue(Validation::notBlank('abcdefg'));
$this->assertTrue(Validation::notBlank('fasdf '));
$this->assertTrue(Validation::notBlank('fooo' . chr(243) . 'blabla'));
$this->assertTrue(Validation::notBlank('abçďĕʑʘπй'));
$this->assertTrue(Validation::notBlank('José'));
$this->assertTrue(Validation::notBlank('é'));
$this->assertTrue(Validation::notBlank('π'));
$this->assertFalse(Validation::notBlank("\t "));
$this->assertFalse(Validation::notBlank(""));
}
/**
@@ -147,14 +147,14 @@ public function testNotEmpty() {
*/
public function testNotEmptyISO88591AppEncoding() {
Configure::write('App.encoding', 'ISO-8859-1');
$this->assertTrue(Validation::notEmpty('abcdefg'));
$this->assertTrue(Validation::notEmpty('fasdf '));
$this->assertTrue(Validation::notEmpty('fooo' . chr(243) . 'blabla'));
$this->assertTrue(Validation::notEmpty('abçďĕʑʘπй'));
$this->assertTrue(Validation::notEmpty('José'));
$this->assertTrue(Validation::notEmpty(utf8_decode('José')));
$this->assertFalse(Validation::notEmpty("\t "));
$this->assertFalse(Validation::notEmpty(""));
$this->assertTrue(Validation::notBlank('abcdefg'));
$this->assertTrue(Validation::notBlank('fasdf '));
$this->assertTrue(Validation::notBlank('fooo' . chr(243) . 'blabla'));
$this->assertTrue(Validation::notBlank('abçďĕʑʘπй'));
$this->assertTrue(Validation::notBlank('José'));
$this->assertTrue(Validation::notBlank(utf8_decode('José')));
$this->assertFalse(Validation::notBlank("\t "));
$this->assertFalse(Validation::notBlank(""));
}
/**
@@ -48,6 +48,19 @@ class Validation {
*/
public static $errors = array();
/**
* Backwards compatibility wrapper for Validation::notBlank().
*
* @param string|array $check Value to check.
* @return bool Success.
* @deprecated 2.7.0 Use Validation::notBlank() instead.
* @see Validation::notBlank()
*/
public function notEmpty($check) {
trigger_error('Validation::notEmpty() is deprecated. Use Validation::notBlank() instead.', E_USER_DEPRECATED);
return self::notBlank($check);
}
/**
* Checks that a string contains something other than whitespace
*
@@ -59,7 +72,7 @@ class Validation {
* @param string|array $check Value to check
* @return bool Success
*/
public static function notEmpty($check) {
public static function notBlank($check) {
if (is_array($check)) {
extract(self::_defaults($check));
}
@@ -143,7 +156,7 @@ public static function blank($check) {
* Returns true if $check is in the proper credit card format.
*
* @param string|array $check credit card number to validate
* @param string|array $type 'all' may be passed as a sting, defaults to fast which checks format of most major credit
* @param string|array $type 'all' may be passed as a sting, defaults to fast which checks format of most major credit
* cards
* if an array is used only the values of the array are checked.
* Example: array('amex', 'bankcard', 'maestro')

0 comments on commit 8662426

Please sign in to comment.