|
@@ 973-991 (lines=19) @@
|
| 970 |
|
* @return Assert |
| 971 |
|
* @throws AssertionFailedException |
| 972 |
|
*/ |
| 973 |
|
public function notEmpty(string $message='', string $fieldName='') : Assert |
| 974 |
|
{ |
| 975 |
|
if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
| 976 |
|
{ |
| 977 |
|
return $this; |
| 978 |
|
} |
| 979 |
|
if ( ( is_object($this->value) && empty((array)$this->value) ) || empty($this->value) ) |
| 980 |
|
{ |
| 981 |
|
$message = $message ?: $this->overrideError; |
| 982 |
|
$message = sprintf( |
| 983 |
|
$message ?: 'Value "%s" is empty, but non empty value was expected.', |
| 984 |
|
$this->stringify($this->value) |
| 985 |
|
); |
| 986 |
|
|
| 987 |
|
throw $this->createException($message, $this->overrideCode ?: self::VALUE_EMPTY, $fieldName); |
| 988 |
|
} |
| 989 |
|
|
| 990 |
|
return $this; |
| 991 |
|
} |
| 992 |
|
|
| 993 |
|
/** |
| 994 |
|
* Assert that value is empty. |
|
@@ 1874-1892 (lines=19) @@
|
| 1871 |
|
* @return Assert |
| 1872 |
|
* @throws AssertionFailedException |
| 1873 |
|
*/ |
| 1874 |
|
public function notBlank(string $message='', string $fieldName='') : Assert |
| 1875 |
|
{ |
| 1876 |
|
if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
| 1877 |
|
{ |
| 1878 |
|
return $this; |
| 1879 |
|
} |
| 1880 |
|
if ( false === $this->value || ( empty( $this->value ) && '0' != $this->value ) ) |
| 1881 |
|
{ |
| 1882 |
|
$message = $message ?: $this->overrideError; |
| 1883 |
|
$message = sprintf( |
| 1884 |
|
$message ?: 'Value "%s" is blank, but was expected to contain a value.', |
| 1885 |
|
$this->stringify($this->value) |
| 1886 |
|
); |
| 1887 |
|
|
| 1888 |
|
throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_BLANK, $fieldName); |
| 1889 |
|
} |
| 1890 |
|
|
| 1891 |
|
return $this; |
| 1892 |
|
} |
| 1893 |
|
|
| 1894 |
|
/** |
| 1895 |
|
* Assert that value is an instance of a given class-name. |