‪TYPO3CMS  10.4
NotEmptyValidator.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
22 {
29  protected ‪$acceptsEmptyValues = false;
30 
36  public function ‪isValid($value)
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 (is_object($value) && $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:27
‪TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator\translateErrorMessage
‪string null translateErrorMessage($translateKey, $extensionName, $arguments=[])
Definition: AbstractValidator.php:153
‪TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator\$acceptsEmptyValues
‪bool $acceptsEmptyValues
Definition: NotEmptyValidator.php:28
‪TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator\isValid
‪isValid($value)
Definition: NotEmptyValidator.php:35
‪TYPO3\CMS\Extbase\Validation\Validator
Definition: AbstractCompositeValidator.php:16
‪TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator
Definition: NotEmptyValidator.php:22
‪TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator\addError
‪addError($message, $code, array $arguments=[], $title='')
Definition: AbstractValidator.php:120