Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
ValidatorHasNotNull.php
Go to the documentation of this file.
1<?php
2
4
7
8abstract 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
String utilities.
Definition UString.php:15