‪TYPO3CMS  ‪main
NotEmptyValidator.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
24 {
31  protected ‪$acceptsEmptyValues = false;
32 
36  public function ‪isValid(mixed $value): void
37  {
38  if ($value === null) {
39  $this->‪addError(
41  'validator.notempty.null',
42  'extbase'
43  ),
44  1221560910
45  );
46  }
47  if ($value === '') {
48  $this->‪addError(
50  'validator.notempty.empty',
51  'extbase'
52  ),
53  1221560718
54  );
55  }
56  if (is_array($value) && empty($value)) {
57  $this->‪addError(
59  'validator.notempty.empty',
60  'extbase'
61  ),
62  1347992400
63  );
64  }
65  if ($value instanceof \Countable && $value->count() === 0) {
66  $this->‪addError(
68  'validator.notempty.empty',
69  'extbase'
70  ),
71  1347992453
72  );
73  }
74  }
75 }
‪TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator
Definition: AbstractValidator.php:29
‪TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator\addError
‪addError(string $message, int $code, array $arguments=[], string $title='')
Definition: AbstractValidator.php:82
‪TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator\$acceptsEmptyValues
‪bool $acceptsEmptyValues
Definition: NotEmptyValidator.php:30
‪TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator\translateErrorMessage
‪translateErrorMessage(string $translateKey, string $extensionName, array $arguments=[])
Definition: AbstractValidator.php:122
‪TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator\isValid
‪isValid(mixed $value)
Definition: NotEmptyValidator.php:35
‪TYPO3\CMS\Extbase\Validation\Validator
Definition: AbstractCompositeValidator.php:18
‪TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator
Definition: NotEmptyValidator.php:24