(no commit message) master
authorChristian Weiske <cweiske@cweiske.de>
Tue, 5 Dec 2017 15:13:25 +0000 (16:13 +0100)
committerwww-cweiske <www-cweiske@localhost.localdomain>
Tue, 5 Dec 2017 15:13:25 +0000 (16:13 +0100)
README.rst [new file with mode: 0644]
RequestValidator.php [new file with mode: 0644]

diff --git a/README.rst b/README.rst
new file mode 100644 (file)
index 0000000..1f80d24
--- /dev/null
@@ -0,0 +1,3 @@
+https://noctus.net/2011/extbase-model-zugriff-in-validatoren is outdated.\r
+\r
+Solution: use forProperty()
\ No newline at end of file
diff --git a/RequestValidator.php b/RequestValidator.php
new file mode 100644 (file)
index 0000000..4bc4577
--- /dev/null
@@ -0,0 +1,23 @@
+<?php\r
+namespace Vnd\Extname\Domain;\r
+\r
+class RequestValidator\r
+    extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator\r
+{\r
+    public function isValid($req)\r
+    {\r
+        if ($req->foo == 5 && $req->bar == '') {\r
+            //require $bar only when $foo is 5\r
+            $this->result->forProperty('bar')->addError(\r
+                new \TYPO3\CMS\Extbase\Validation\Error(\r
+                    $this->translateErrorMessage(\r
+                        'validator.notempty.empty',\r
+                        'extbase'\r
+                    ),\r
+                    1221560910\r
+                )\r
+            );\r
+        }\r
+    }\r
+}\r
+?>\r