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