Ubiquity
2.5.2
php rapid development framework
Loading...
Searching...
No Matches
ValidatorHasNotNull.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Ubiquity\contents\validation\validators
;
4
5
use
Ubiquity\exceptions\ValidatorException
;
6
use
Ubiquity\utils\base\UString
;
7
8
abstract
class
ValidatorHasNotNull
extends
Validator
implements
HasNotNullInterface
{
9
protected
$notNull
;
10
11
public
function
validate
(
$value
) {
12
if
($this->notNull !==
false
&& (
null
===
$value
||
''
===
$value
)) {
13
return
;
14
}
15
if
($this->notNull ===
true
&& ! UString::isValid (
$value
)) {
16
throw
new
ValidatorException
(
'This value can not be converted to string'
);
17
}
18
}
19
20
public
function
asUI
(): array {
21
if ($this->notNull) {
22
return
[
'rules'
=> [
'empty'
] ];
23
}
24
return
[ ];
25
}
26
}
27
Ubiquity\contents\validation\validators\ValidatorHasNotNull
Definition
ValidatorHasNotNull.php:8
Ubiquity\contents\validation\validators\ValidatorHasNotNull\$notNull
$notNull
Definition
ValidatorHasNotNull.php:9
Ubiquity\contents\validation\validators\ValidatorHasNotNull\validate
validate($value)
Definition
ValidatorHasNotNull.php:11
Ubiquity\contents\validation\validators\ValidatorHasNotNull\asUI
asUI()
Definition
ValidatorHasNotNull.php:20
Ubiquity\contents\validation\validators\Validator
Abstract class for validators.
Definition
Validator.php:11
Ubiquity\contents\validation\validators\Validator\$value
$value
Definition
Validator.php:15
Ubiquity\exceptions\ValidatorException
Validator Exceptions.
Definition
ValidatorException.php:11
Ubiquity\utils\base\UString
String utilities.
Definition
UString.php:15
Ubiquity\contents\validation\validators\HasNotNullInterface
Definition
HasNotNullInterface.php:5
Ubiquity\contents\validation\validators
Validators definition.
C:
Users
myadd
Documents
GitHub
ubiquity-doc-api
vendor
phpmv
ubiquity
src
Ubiquity
contents
validation
validators
ValidatorHasNotNull.php
Generated on Sun Dec 10 2023 15:04:16 for
Ubiquity
by
doxygen
1.9.8