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