* first steps towards $_GET and $_POST argument validation taken
authorJochen Rau <j.rau@web.de>
Wed, 25 Feb 2009 09:33:31 +0000 (09:33 +0000)
committerJochen Rau <j.rau@web.de>
Wed, 25 Feb 2009 09:33:31 +0000 (09:33 +0000)
26 files changed:
typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_AbstractController.php
typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_ActionController.php
typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_Argument.php
typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_Arguments.php
typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_ArgumentsValidator.php
typo3/sysext/extbase/Classes/TX_EXTMVC_Request.php
typo3/sysext/extbase/Classes/Validation/Exception/TX_EXTMVC_Persistence_InvalidChainIndex.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/Exception/TX_EXTMVC_Persistence_InvalidSubject.php [new file with mode: 0755]
typo3/sysext/extbase/Classes/Validation/Exception/TX_EXTMVC_Persistence_NoValidatorFound.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_Error.php [new file with mode: 0755]
typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_Errors.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_Exception.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_ValidatorInterface.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_ValidatorResolver.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Alphanumeric.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_EmailAddress.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Float.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Integer.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_NotEmpty.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Number.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_NumberRange.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Raw.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_RegularExpression.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Text.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_UUID.php [new file with mode: 0644]
typo3/sysext/extbase/class.tx_extmvc_dispatcher.php

index b001f2a..fefdaa1 100755 (executable)
@@ -187,7 +187,13 @@ abstract class TX_EXTMVC_Controller_AbstractController implements TX_EXTMVC_Cont
         */
        protected function mapRequestArgumentsToLocalArguments() {
                $this->setAllowedProperties(array_merge($this->arguments->getArgumentNames(), $this->arguments->getArgumentShortNames()));
-               $this->map($this->request->getArguments());
+               $requestArguments = $this->request->getArguments();
+               foreach ($requestArguments as $requestArgument) {
+                       if ($this->isAllowedProperty($requestArgument->getName())) {
+                               $argument = $this->arguments->getArgument($requestArgument->getName());
+                               $argument->setValue($requestArgument->getValue());
+                       }
+               }
        }
        
        /**
@@ -232,30 +238,6 @@ abstract class TX_EXTMVC_Controller_AbstractController implements TX_EXTMVC_Cont
                return $isAllowed;
        }
        
-       /**
-        * Maps the given properties to the target object.
-        * After mapping the results can be retrieved with getMappingResult.
-        *
-        * In case the $target object is directly given to this method, it modifies
-        * the given $target object and the validator and allowedProperties are
-        * reset to their default values.
-        *
-        * @param object $properties Properties to map
-        * @param array $allowedProperties Optional. An array of allowed property names. Each entry in this array may be a regular expression. Will be used instead of this->setAllowedProperties, if it is set.
-        * @return void
-        * @author Jochen Rau <jochen.rau@typoplanet.de>
-        */
-       protected function map($properties, $allowedProperties = NULL) {
-               $getParameters = t3lib_div::_GET();
-               $postParameters = t3lib_div::_POST();
-               foreach ($getParameters as $key => $value) {
-                       if ($this->isAllowedProperty($key)) {
-                               $argument = $this->arguments->getArgument($key);
-                               $argument->setValue($value);
-                       }
-               }
-       }
-
 }
 
 ?>
\ No newline at end of file
index 7543d6e..c959d10 100644 (file)
@@ -70,38 +70,6 @@ class TX_EXTMVC_Controller_ActionController extends TX_EXTMVC_Controller_Abstrac
                $this->callActionMethod();
        }
 
-       /**
-        * Implementation of the arguments initilization in the action controller:
-        * Automatically registers arguments of the current action
-        *
-        * IMPORTANT: If this method is overridden, make sure to call this parent
-        *            _before_ your own code because otherwise the order of automatically
-        *            registered arguments wouldn't match the action method signature.
-        *
-        * @return void
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       protected function initializeArguments() {
-               $methodParameters = $this->reflectionService->getMethodParameters(get_class($this), $this->actionMethodName);
-               $methodTagsAndValues = $this->reflectionService->getMethodTagsValues(get_class($this), $this->actionMethodName);
-               foreach ($methodParameters as $parameterName => $parameterInfo) {
-                       $dataType = 'Text';
-                       if (isset($methodTagsAndValues['param']) && count($methodTagsAndValues['param']) > 0) {
-                               $explodedTagValue = explode(' ', array_shift($methodTagsAndValues['param']));
-                               switch ($explodedTagValue[0]) {
-                                       case 'integer' :
-                                               $dataType = 'Integer';
-                                       break;
-                                       default:
-                                               if (strpos($dataType, '\\') !== FALSE) {
-                                                       $dataType = $explodedTagValue[0];
-                                               }
-                               }
-                       }
-                       $this->arguments->addNewArgument($parameterName, $dataType);
-               }
-       }
-
        /**
         * Determines the action method and assures that the method exists.
         *
index 39f656f..802f757 100644 (file)
@@ -77,7 +77,6 @@ class TX_EXTMVC_Controller_Argument {
         *
         * @param string $name Name of this argument
         * @param string $dataType The data type of this argument
-        * @param F3_FLOW3_Object_ManagerInterface The object manager
         * @throws InvalidArgumentException if $name is not a string or empty
         * @author Robert Lemke <robert@typo3.org>
         */
index 49314d9..ae6d59f 100644 (file)
@@ -42,7 +42,7 @@ class TX_EXTMVC_Controller_Arguments extends ArrayObject {
         * argument object itself, therefore the $offset does not have any meaning in this context.
         *
         * @param mixed $offset Offset - not used here
-        * @param mixed $value The argument.
+        * @param mixed $value The argument
         * @return void
         * @throws InvalidArgumentException if the argument is not a valid Controller Argument object
         * @author Robert Lemke <robert@typo3.org>
index 26eaf9d..9560799 100644 (file)
@@ -28,12 +28,7 @@ declare(ENCODING = 'utf-8');
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  * @scope prototype
  */
-class ArgumentsValidator implements F3_FLOW3_Validation_ObjectValidatorInterface {
-
-       /**
-        * @var F3_FLOW3_Object_FactoryInterface The object factory
-        */
-       protected $objectFactory;
+class TX_EXTMVC_controller_ArgumentsValidator {
 
        /**
         * @var TX_EXTMVC_Controller_Arguments The registered arguments with the specified property validators
@@ -44,11 +39,9 @@ class ArgumentsValidator implements F3_FLOW3_Validation_ObjectValidatorInterface
         * Constructor
         *
         * @param TX_EXTMVC_Controller_Arguments The registered arguments with the specified property editors
-        * @param F3_FLOW3_Object_FactoryInterface The object factory
         * @author Andreas Förthner <andreas.foerthner@netlogix.de>
         */
-       public function __construct(TX_EXTMVC_Controller_Arguments $registeredArguments, F3_FLOW3_Object_FactoryInterface $objectFactory) {
-               $this->objectFactory = $objectFactory;
+       public function __construct(TX_EXTMVC_Controller_Arguments $registeredArguments) {
                $this->registeredArguments = $registeredArguments;
        }
 
@@ -69,12 +62,12 @@ class ArgumentsValidator implements F3_FLOW3_Validation_ObjectValidatorInterface
         * least one error occurred, the result is FALSE.
         *
         * @param object $object: The object which is supposed to be validated.
-        * @param F3_FLOW3_Validation_Errors $errors: Here any occured validation error is stored
+        * @param TX_EXTMVC_Validation_Errors $errors: Here any occured validation error is stored
         * @return boolean TRUE if validation succeeded completely, FALSE if at least one error occurred.
-        * @throws F3_FLOW3_Validation_Exception_InvalidSubject if this validator cannot validate the given subject or the subject is not an object.
+        * @throws TX_EXTMVC_Validation_Exception_InvalidSubject if this validator cannot validate the given subject or the subject is not an object.
         */
-       public function validate($object, F3_FLOW3_Validation_Errors &$errors) {
-               if (!$object instanceof TX_EXTMVC_Controller_Arguments) throw new F3_FLOW3_Validation_Exception_InvalidSubject('The specified object cannot be validated by this validator.', 1216720829);
+       public function validate($object, TX_EXTMVC_Validation_Errors &$errors) {
+               if (!$object instanceof TX_EXTMVC_Controller_Arguments) throw new TX_EXTMVC_Validation_Exception_InvalidSubject('The specified object cannot be validated by this validator.', 1216720829);
 
                $isValid = TRUE;
                foreach ($object as $argument) {
@@ -91,12 +84,12 @@ class ArgumentsValidator implements F3_FLOW3_Validation_ObjectValidatorInterface
         *
         * @param object $object: The object of which the property should be validated
         * @param string $propertyName: The name of the property that should be validated
-        * @param F3_FLOW3_Validation_Errors $errors: Here any occured validation error is stored
+        * @param TX_EXTMVC_Validation_Errors $errors: Here any occured validation error is stored
         * @return boolean TRUE if the property could be validated, FALSE if an error occured
-        * @throws F3_FLOW3_Validation_Exception_InvalidSubject if this validator cannot validate the given subject or the subject is not an object.
+        * @throws TX_EXTMVC_Validation_Exception_InvalidSubject if this validator cannot validate the given subject or the subject is not an object.
         */
-       public function validateProperty($object, $propertyName, F3_FLOW3_Validation_Errors &$errors) {
-               if (!$object instanceof TX_EXTMVC_Controller_Arguments) throw new F3_FLOW3_Validation_Exception_InvalidSubject('The specified object cannot be validated by this validator.', 1216720830);
+       public function validateProperty($object, $propertyName, TX_EXTMVC_Validation_Errors &$errors) {
+               if (!$object instanceof TX_EXTMVC_Controller_Arguments) throw new TX_EXTMVC_Validation_Exception_InvalidSubject('The specified object cannot be validated by this validator.', 1216720830);
 
                $propertyValidatorErrors = $this->createNewValidationErrorsObject();
 
@@ -119,7 +112,7 @@ class ArgumentsValidator implements F3_FLOW3_Validation_ObjectValidatorInterface
         * @param object $propertyValue: The value that should be validated
         * @return boolean TRUE if the value could be validated for the given property, FALSE if an error occured
         */
-       public function isValidProperty($className, $propertyName, $propertyValue, F3_FLOW3_Validation_Errors &$errors) {
+       public function isValidProperty($className, $propertyName, $propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
                $propertyValidatorErrors = $this->createNewValidationErrorsObject();
 
                $isValid = TRUE;
@@ -134,11 +127,11 @@ class ArgumentsValidator implements F3_FLOW3_Validation_ObjectValidatorInterface
        /**
         * This is a factory method to get a clean validation errors object
         *
-        * @return F3_FLOW3_Validation_Errors An empty errors object
+        * @return TX_EXTMVC_Validation_Errors An empty errors object
         * @author Andreas Förthner <andreas.foerthner@netlogix.de>
         */
        protected function createNewValidationErrorsObject() {
-               return t3lib_div::makeInstance('F3_FLOW3_Validation_Errors');
+               return t3lib_div::makeInstance('TX_EXTMVC_Validation_Errors');
        }
 }
 ?>
\ No newline at end of file
index 21f47f2..320ca69 100644 (file)
@@ -293,7 +293,7 @@ class TX_EXTMVC_Request {
         * @return void
         * @author Robert Lemke <robert@typo3.org>
         */
-       public function setArguments(_ArrayObject $arguments) {
+       public function setArguments(ArrayObject $arguments) {
                $this->arguments = $arguments;
        }
 
diff --git a/typo3/sysext/extbase/Classes/Validation/Exception/TX_EXTMVC_Persistence_InvalidChainIndex.php b/typo3/sysext/extbase/Classes/Validation/Exception/TX_EXTMVC_Persistence_InvalidChainIndex.php
new file mode 100644 (file)
index 0000000..8ac033d
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+declare(ENCODING = 'utf-8');
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ */
+
+/**
+ * An "Invalid Chain Index" Exception for a validator chain
+ *
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_Validation_InvalidChainIndex extends TX_EXTMVC_Validation_Exception {
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/Exception/TX_EXTMVC_Persistence_InvalidSubject.php b/typo3/sysext/extbase/Classes/Validation/Exception/TX_EXTMVC_Persistence_InvalidSubject.php
new file mode 100755 (executable)
index 0000000..3d5b1c9
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+declare(ENCODING = 'utf-8');
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ */
+
+/**
+ * An "Invalid Subject" Exception
+ *
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_Validation_InvalidSubject extends TX_EXTMVC_Validation_Exception {
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/Exception/TX_EXTMVC_Persistence_NoValidatorFound.php b/typo3/sysext/extbase/Classes/Validation/Exception/TX_EXTMVC_Persistence_NoValidatorFound.php
new file mode 100644 (file)
index 0000000..fe3441f
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+declare(ENCODING = 'utf-8');
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ */
+
+/**
+ * A "NoValidatorFound" Exception
+ *
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_Validation_NoValidatorFound extends TX_EXTMVC_Validation_Exception {
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_Error.php b/typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_Error.php
new file mode 100755 (executable)
index 0000000..5e3500d
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+declare(ENCODING = 'utf-8');
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * This object holds a validation error.
+ *
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class TX_EXTMVC_Validation_Error extends TX_EXTMVC_Error_Error {
+
+       /**
+        * @var string The default (english) error message.
+        */
+       protected $message = 'Unknown validation error';
+
+       /**
+        * @var string The error code
+        */
+       protected $code = 1201447005;
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_Errors.php b/typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_Errors.php
new file mode 100644 (file)
index 0000000..4af2899
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+declare(ENCODING = 'utf-8');
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Objects of this kind contain a list of validation errors which occurred during
+ * validation.
+ *
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class TX_EXTMVC_Validation_Errors extends ArrayObject {
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_Exception.php b/typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_Exception.php
new file mode 100644 (file)
index 0000000..0038dc1
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+declare(ENCODING = 'utf-8');
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * A generic validation exception
+ * 
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_Validation_Exception extends TX_EXTMVC_Exception {
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_ValidatorInterface.php b/typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_ValidatorInterface.php
new file mode 100644 (file)
index 0000000..13a33d5
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+declare(ENCODING = 'utf-8');
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Contract for a validator
+ *
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+interface TX_EXTMVC_Validation_ValidatorInterface {
+
+       /**
+        * Returns TRUE, if the given propterty ($proptertyValue) is a valid.
+        * Any errors will be stored in the given errors object.
+        * If at least one error occurred, the result is FALSE.
+        *
+        * @param  object $propertyValue: The value that should be validated
+        * @return boolean TRUE if the value could be validated. FALSE if an error occured
+        * @throws TX_EXTMVC_Validation_Exception_InvalidSubject if this validator cannot validate the given subject or the subject is not an object.
+        */
+       public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors);
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_ValidatorResolver.php b/typo3/sysext/extbase/Classes/Validation/TX_EXTMVC_Validation_ValidatorResolver.php
new file mode 100644 (file)
index 0000000..94c34ad
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+declare(ENCODING = 'utf-8');
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Validator resolver to automatically find a appropriate validator for a given subject
+ *
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_Validation_ValidatorResolver {
+
+       /**
+        * Returns an object of an appropriate validator for the given class. If no validator is available
+        * a TX_EXTMVC_Validation_Exception_NoValidatorFound exception is thrown.
+        * @param string The classname for which validator is needed
+        * @return object The resolved validator object
+        * @throws TX_EXTMVC_Validation_Exception_NoValidatorFound
+        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
+        */
+       public function resolveValidator($class) {
+               $validatorName = $class . 'Validator';
+               if (!$this->objectManager->isObjectRegistered($validatorName)) throw new TX_EXTMVC_Validation_Exception_NoValidatorFound('No validator with name ' . $validatorName . ' found!', 1211036055);
+               $validator = $this->objectManager->getObject($validatorName);
+               if (!($validator instanceof TX_EXTMVC_Validation_ObjectValidatorInterface)) throw new TX_EXTMVC_Validation_Exception_NoValidatorFound('The found validator class did not implement TX_EXTMVC_Validation_ObjectValidatorInterface', 1211036068);
+               return $validator;
+       }
+
+       /**
+        * Returns the name of an appropriate validator for the given class. If no validator is available
+        * a TX_EXTMVC_Validation_Exception_NoValidatorFound exception is thrown.
+        * @param string The classname for which validator is needed
+        * @return object The resolved validator object
+        * @throws TX_EXTMVC_Validation_Exception_NoValidatorFound
+        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
+        */
+       public function resolveValidatorName($class) {
+               $validatorName = $class . 'Validator';
+               if (!$this->objectManager->isObjectRegistered($validatorName)) throw new TX_EXTMVC_Validation_Exception_NoValidatorFound('No validator with name ' . $validatorName . ' found!', 1211036084);
+               $validator = $this->objectManager->getObject($validatorName);
+               if (!($validator instanceof TX_EXTMVC_Validation_ObjectValidatorInterface)) throw new TX_EXTMVC_Validation_Exception_NoValidatorFound('The found validator class did not implement TX_EXTMVC_Validation_ObjectValidatorInterface', 1211036095);
+               return $validatorName;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Alphanumeric.php b/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Alphanumeric.php
new file mode 100644 (file)
index 0000000..ad5fa7e
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+declare(ENCODING = 'utf-8');
+namespace TX_EXTMVC_Validation_Validator;
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ */
+
+/**
+ * Validator for alphanumeric strings
+ *
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_Validation_Alphanumeric {
+
+       /**
+        * Returns TRUE, if the given property ($propertyValue) is a valid
+        * alphanumeric string, which is defined as [a-zA-Z0-9]*.
+        * Any errors will be stored in the given errors object.
+        * If at least one error occurred, the result is FALSE.
+        *
+        * @param mixed $propertyValue The value that should be validated
+        * @param TX_EXTMVC_Validation_Errors $errors Any occured Error will be stored here
+        * @return boolean TRUE if the value could be validated. FALSE if an error occured
+        * @throws TX_EXTMVC_Validation_Exception_InvalidSubject if this validator cannot validate the given subject or the subject is not an object.
+        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
+
+               if (is_string($propertyValue) && preg_match('/^[a-z0-9]*$/i', $propertyValue)) return TRUE;
+
+               $errors->append($this->objectFactory->create('TX_EXTMVC_Validation_Error', 'The given subject was not a valid integer. Got: "' . $propertyValue . '"', 1221551320));
+               return FALSE;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_EmailAddress.php b/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_EmailAddress.php
new file mode 100644 (file)
index 0000000..9887528
--- /dev/null
@@ -0,0 +1,161 @@
+<?php
+declare(ENCODING = 'utf-8');
+namespace TX_EXTMVC_Validation_Validator;
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ */
+
+/**
+ * Validator for email addresses
+ *
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_Validation_EmailAddress {
+
+       /**
+        * Returns TRUE, if the given property ($proptertyValue) is a valid email address.
+        * Any errors will be stored in the given errors object.
+        * If at least one error occurred, the result is FALSE.
+        *
+        * The regexp is a modified version of the last one shown on
+        * http://www.regular-expressions.info/email.html
+        *
+        * Still it will probably miss a lot of technically valid addresses, see RFC822
+        * for the whole mumbo-jumbo. Or have a look at this:
+        *
+        * (?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
+        * )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:
+        * \r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(
+        * ?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[
+        * \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\0
+        * 31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\
+        * ](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+
+        * (?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:
+        * (?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
+        * |(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)
+        * ?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\
+        * r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[
+        *  \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)
+        * ?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t]
+        * )*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[
+        *  \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*
+        * )(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
+        * )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)
+        * *:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+
+        * |\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r
+        * \n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:
+        * \r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t
+        * ]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031
+        * ]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](
+        * ?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?
+        * :(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?
+        * :\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?
+        * :(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?
+        * [ \t]))*"(?:(?:\r\n)?[ \t])*)*:(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\]
+        * \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|
+        * \\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>
+        * @,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"
+        * (?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t]
+        * )*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
+        * ".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?
+        * :[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[
+        * \]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-
+        * \031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(
+        * ?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;
+        * :\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([
+        * ^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\"
+        * .\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\
+        * ]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\
+        * [\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\
+        * r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\]
+        * \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]
+        * |\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \0
+        * 00-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\
+        * .|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,
+        * ;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?
+        * :[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*
+        * (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".
+        * \[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[
+        * ^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]
+        * ]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)(?:,\s*(
+        * ?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
+        * ".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(
+        * ?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[
+        * \["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t
+        * ])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t
+        * ])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?
+        * :\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|
+        * \Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:
+        * [^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\
+        * ]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)
+        * ?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["
+        * ()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)
+        * ?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>
+        * @,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[
+        *  \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,
+        * ;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t]
+        * )*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
+        * ".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?
+        * (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".
+        * \[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:
+        * \r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\[
+        * "()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])
+        * *))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])
+        * +|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\
+        * .(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
+        * |(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(
+        * ?:\r\n)?[ \t])*))*)?;\s*)
+        * (from http://ex-parrot.com/~pdw/Mail-RFC822-Address.html)
+        *
+        * @param mixed $propertyValue The value that should be validated
+        * @param TX_EXTMVC_Validation\Errors $errors Any occured Error will be stored here
+        * @return boolean TRUE if the value could be validated. FALSE if an error occured
+        * @throws TX_EXTMVC_Validation_Exception\InvalidSubject if this validator cannot validate the given subject or the subject is not an object.
+        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       public function isValidProperty($propertyValue, TX_EXTMVC_Validation\Errors &$errors) {
+
+               if(is_string($propertyValue) && preg_match('
+                               /
+                                       [a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*
+                                       @
+                                       (?:
+                                               (?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[a-z]{2}|aero|asia|biz|cat|com|edu|coop|gov|info|int|invalid|jobs|localdomain|mil|mobi|museum|name|net|org|pro|tel|travel)|
+                                               localhost|
+                                               (?:(?:\d{1,2}|1\d{1,2}|2[0-5][0-5])\.){3}(?:(?:\d{1,2}|1\d{1,2}|2[0-5][0-5]))
+                                       )
+                                       \b
+                               /ix', $propertyValue)) return TRUE;
+               $errors->append($this->objectFactory->create('TX_EXTMVC_Validation_Error', 'The given subject was not a valid email address. Got: "' . $propertyValue . '"', 1221559976));
+               return FALSE;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Float.php b/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Float.php
new file mode 100644 (file)
index 0000000..1b37ebe
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+declare(ENCODING = 'utf-8');
+namespace TX_EXTMVC_Validation_Validator;
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ */
+
+/**
+ * Validator for floats
+ *
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_Validation_Float {
+
+       /**
+        * Returns TRUE, if the given propterty ($proptertyValue) is a valid float.
+        * Any errors will be stored in the given errors object.
+        * If at least one error occurred, the result is FALSE.
+        *
+        * @param  object $propertyValue The value that should be validated
+        * @param TX_EXTMVC_Validation_Errors $errors Any occured Error will be stored here
+        * @return boolean TRUE if the value could be validated. FALSE if an error occured
+        * @throws TX_EXTMVC_Validation_Exception_InvalidSubject if this validator cannot validate the given subject or the subject is not an object.
+        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
+
+               if (is_float($propertyValue)) return TRUE;
+               if (is_string($propertyValue) && strpos($propertyValue, '.') && preg_match('/^[0-9.e+-]+$/', $propertyValue)) return TRUE;
+
+               $errors->append($this->objectFactory->create('TX_EXTMVC_Validation_Error', 'The given subject was not a valid float. Got: "' . $propertyValue . '"', 1221560288));
+               return FALSE;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Integer.php b/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Integer.php
new file mode 100644 (file)
index 0000000..28bd7fc
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+declare(ENCODING = 'utf-8');
+namespace TX_EXTMVC_Validation_Validator;
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ */
+
+/**
+ * Validator for integers
+ *
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_Validation_Integer {
+
+       /**
+        * Returns TRUE, if the given propterty ($proptertyValue) is a valid integer.
+        * Any errors will be stored in the given errors object.
+        * If at least one error occurred, the result is FALSE.
+        *
+        * @param mixed $propertyValue The value that should be validated
+        * @param TX_EXTMVC_Validation_Errors $errors Any occured Error will be stored here
+        * @return boolean TRUE if the value could be validated. FALSE if an error occured
+        * @throws TX_EXTMVC_Validation_Exception_InvalidSubject if this validator cannot validate the given subject or the subject is not an object.
+        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
+
+               if (filter_var($propertyValue, FILTER_VALIDATE_INT) !== FALSE) return TRUE;
+
+               $errors->append($this->objectFactory->create('TX_EXTMVC_Validation_Error', 'The given subject was not a valid integer. Got: "' . $propertyValue . '"', 1221560494));
+               return FALSE;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_NotEmpty.php b/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_NotEmpty.php
new file mode 100644 (file)
index 0000000..483ec84
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+declare(ENCODING = 'utf-8');
+namespace TX_EXTMVC_Validation_Validator;
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ */
+
+/**
+ * Validator for not empty values
+ *
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_Validation_NotEmpty {
+
+       /**
+        * Returns TRUE, if the given propterty ($proptertyValue) is not empty (NULL or empty string).
+        * Any errors will be stored in the given errors object.
+        * If at least one error occurred, the result is FALSE.
+        *
+        * @param mixed $propertyValue The value that should be validated
+        * @param TX_EXTMVC_Validation_Errors $errors Any occured Error will be stored here
+        * @return boolean TRUE if the value could be validated. FALSE if an error occured
+        * @throws TX_EXTMVC_Validation_Exception_InvalidSubject if this validator cannot validate the given subject or the subject is not an object.
+        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
+               if ($propertyValue === NULL) {
+                       $errors->append($this->objectFactory->create('TX_EXTMVC_Validation_Error', 'The given subject was NULL.', 1221560910));
+                       return FALSE;
+               }
+               if ($propertyValue === '') {
+                       $errors->append($this->objectFactory->create('TX_EXTMVC_Validation_Error', 'The given subject was empty.', 1221560718));
+                       return FALSE;
+               }
+
+               return TRUE;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Number.php b/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Number.php
new file mode 100644 (file)
index 0000000..8a30f60
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+declare(ENCODING = 'utf-8');
+namespace TX_EXTMVC_Validation_Validator;
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ */
+
+/**
+ * Validator for general numbers
+ *
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_Validation_Number {
+
+       /**
+        * Returns TRUE, if the given propterty ($proptertyValue) is a valid number.
+        * Any errors will be stored in the given errors object.
+        * If at least one error occurred, the result is FALSE.
+        *
+        * @param mixed $propertyValue The value that should be validated
+        * @param TX_EXTMVC_Validation_Errors $errors Any occured Error will be stored here
+        * @return boolean TRUE if the value could be validated. FALSE if an error occured
+        * @throws TX_EXTMVC_Validation_Exception_InvalidSubject if this validator cannot validate the given subject or the subject is not an object.
+        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
+
+               if (is_numeric($propertyValue)) return TRUE;
+
+               $errors->append($this->objectFactory->create('TX_EXTMVC_Validation_Error', 'The given subject was not a valid number. Got: "' . $propertyValue . '"', 1221563685));
+               return FALSE;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_NumberRange.php b/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_NumberRange.php
new file mode 100644 (file)
index 0000000..047fc11
--- /dev/null
@@ -0,0 +1,91 @@
+<?php
+declare(ENCODING = 'utf-8');
+namespace TX_EXTMVC_Validation_Validator;
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ */
+
+/**
+ * Validator for general numbers
+ *
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_Validation_NumberRange {
+
+       /**
+        * The start value of the range
+        * @var number
+        */
+       protected $startRange;
+
+       /**
+        * The end value of the range
+        * @var number
+        */
+       protected $endRange;
+
+       /**
+        * Constructor
+        *
+        * @param number The start of the range
+        * @param number The end of the range
+        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
+        */
+       public function __construct($startRange, $endRange) {
+               if ($startRange > $endRange) {
+                       $this->endRange = $startRange;
+                       $this->startRange = $endRange;
+               } else {
+                       $this->endRange = $endRange;
+                       $this->startRange = $startRange;
+               }
+       }
+
+       /**
+        * Returns TRUE, if the given propterty ($proptertyValue) is a valid number in the given range.
+        * Any errors will be stored in the given errors object.
+        * If at least one error occurred, the result is FALSE.
+        *
+        * @param mixed $propertyValue The value that should be validated
+        * @param TX_EXTMVC_Validation_Errors $errors Any occured Error will be stored here
+        * @return boolean TRUE if the value could be validated. FALSE if an error occured
+        * @throws TX_EXTMVC_Validation_Exception_InvalidSubject if this validator cannot validate the given subject or the subject is not an object.
+        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
+        */
+       public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
+
+               if (!is_numeric($propertyValue)) $errors->append($this->objectFactory->create('TX_EXTMVC_Validation_Error', 'The given subject was not a valid number. Got: "' . $propertyValue . '"', 1221563685));
+               if ($propertyValue < $this->startRange || $propertyValue > $this->endRange) $errors->append($this->objectFactory->create('TX_EXTMVC_Validation_Error', 'The given subject was not in the valid range (' . $this->startRange . ', ' . $this->endRange . '). Got: "' . $propertyValue . '"', 1221561046));
+
+               if (count($errors) > 0) return FALSE;
+               return TRUE;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Raw.php b/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Raw.php
new file mode 100644 (file)
index 0000000..3e23191
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+declare(ENCODING = 'utf-8');
+namespace TX_EXTMVC_Validation_Validator;
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ */
+
+/**
+ * A validator which accepts any input
+ *
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_Validation_Raw implements TX_EXTMVC_Validation_ValidatorInterface {
+
+       /**
+        * Always returns TRUE.
+        *
+        * @param mixed $propertyValue ignored
+        * @param TX_EXTMVC_Validation_Errors $errors ignored
+        * @return boolean Always TRUE
+        * @author Robert Lemke <robert@typo3.org>
+        */
+       public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
+               return TRUE;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_RegularExpression.php b/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_RegularExpression.php
new file mode 100644 (file)
index 0000000..33492b0
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+declare(ENCODING = 'utf-8');
+namespace TX_EXTMVC_Validation_Validator;
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ */
+
+/**
+ * Validator for regular expressions
+ *
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_Validation_RegularExpression {
+
+       /**
+        * @var string The regular expression
+        */
+       protected $regularExpression;
+
+       /**
+        * Creates a RegularExpression validator with the given expression
+        *
+        * @param string The regular expression, must be ready to use with preg_match()
+        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
+        */
+       public function __construct($regularExpression) {
+               $this->regularExpression = $regularExpression;
+       }
+
+       /**
+        * Returns TRUE, if the given propterty ($proptertyValue) matches the given regular expression.
+        * Any errors will be stored in the given errors object.
+        * If at least one error occurred, the result is FALSE.
+        *
+        * @param mixed $propertyValue The value that should be validated
+        * @param TX_EXTMVC_Validation_Errors $errors Any occured Error will be stored here
+        * @return boolean TRUE if the value could be validated. FALSE if an error occured
+        * @throws TX_EXTMVC_Validation_Exception_InvalidSubject if this validator cannot validate the given subject or the subject is not an object.
+        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
+
+               if (!is_string($propertyValue) || preg_match($this->regularExpression, $propertyValue) === 0) {
+                       $errors->append($this->objectFactory->create('TX_EXTMVC_Validation_Error', 'The given subject did not match the pattern. Got: "' . $propertyValue . '"', 1221565130));
+                       return FALSE;
+               }
+
+               return TRUE;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Text.php b/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_Text.php
new file mode 100644 (file)
index 0000000..6650e49
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+declare(ENCODING = 'utf-8');
+namespace TX_EXTMVC_Validation_Validator;
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ */
+
+/**
+ * Validator for text
+ *
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_Validation_Text {
+
+       /**
+        * Returns TRUE, if the given propterty ($propertyValue) is a valid text (contains no XML tags).
+        * Any errors will be stored in the given errors object.
+        * If at least one error occurred, the result is FALSE.
+        *
+        * @param mixed $propertyValue The value that should be validated
+        * @param TX_EXTMVC_Validation_Errors $errors Any occured Error will be stored here
+        * @return boolean TRUE if the value could be validated. FALSE if an error occured
+        * @throws TX_EXTMVC_Validation_Exception_InvalidSubject if this validator cannot validate the given subject or the subject is not an object.
+        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
+
+               if (!is_string($propertyValue) || preg_match('/<[_/]*[a-z,A-Z,0-9]*>/', $propertyValue)) {
+                       $errors->append($this->objectFactory->create('TX_EXTMVC_Validation_Error', 'The given subject was not a valid text (contained XML tags). Got: "' . $propertyValue . '"', 1221565786));
+                       return FALSE;
+               }
+
+               return TRUE;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_UUID.php b/typo3/sysext/extbase/Classes/Validation/Validator/TX_EXTMVC_Persistence_UUID.php
new file mode 100644 (file)
index 0000000..ef779fa
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+declare(ENCODING = 'utf-8');
+namespace TX_EXTMVC_Validation_Validator;
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ */
+
+/**
+ * Validator for Universally Unique Identifiers
+ *
+ * @package FLOW3
+ * @subpackage Validation
+ * @version $ID:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class TX_EXTMVC_Validation_UUID {
+
+       /**
+        * Returns TRUE, if the given property ($propertyValue) is a formally valid UUID.
+        * Any errors will be stored in the given errors object.
+        * If at least one error occurred, the result is FALSE.
+        *
+        * @param mixed $propertyValue The value that should be validated
+        * @param TX_EXTMVC_Validation_Errors $errors Any occured Error will be stored here
+        * @return boolean TRUE if the value could be validated. FALSE if an error occured
+        * @throws TX_EXTMVC_Validation_Exception_InvalidSubject if this validator cannot validate the given subject or the subject is not an object.
+        * @author Robert Lemke <robert@typo3.org>
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        */
+       public function isValidProperty($propertyValue, TX_EXTMVC_Validation_Errors &$errors) {
+               if (!is_string($propertyValue) || !preg_match('/([a-f0-9]){8}-([a-f0-9]){4}-([a-f0-9]){4}-([a-f0-9]){4}-([a-f0-9]){12}/', $propertyValue)) {
+                       $errors->append($this->objectFactory->create('TX_EXTMVC_Validation_Error', 'The given subject was not a valid UUID. Got: "' . $propertyValue . '"', 1221565853));
+                       return FALSE;
+               }
+
+               return TRUE;
+       }
+}
+
+?>
\ No newline at end of file
index c8fbb2a..c7fe76a 100644 (file)
@@ -29,6 +29,8 @@ require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/TX_EXTMVC_Response.php')
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Web/TX_EXTMVC_Web_Response.php');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Controller/TX_EXTMVC_Controller_AbstractController.php');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Controller/TX_EXTMVC_Controller_ActionController.php');
+require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Controller/TX_EXTMVC_Controller_Arguments.php');
+require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Controller/TX_EXTMVC_Controller_Argument.php');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/View/TX_EXTMVC_View_AbstractView.php');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Persistence/TX_EXTMVC_Persistence_Session.php');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Persistence/Mapper/TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper.php');
@@ -88,12 +90,18 @@ class TX_EXTMVC_Dispatcher {
        public function dispatch($content, $configuration) {
                // debug($configuration);
                // TODO instantiate the configurationManager
-
+               $arguments = t3lib_div::makeInstance('TX_EXTMVC_Controller_Arguments');
+               foreach (t3lib_div::GParrayMerged(strtolower('tx_' . $configuration['extension'])) as $key => $value) {
+                       $argument = new TX_EXTMVC_Controller_Argument($key);
+                       $argument->setValue($value);
+                       $argument->setValidity(FALSE);
+                       $arguments->addArgument($argument);
+               }
                $request = t3lib_div::makeInstance('TX_EXTMVC_Web_Request');
                $request->setControllerExtensionKey($configuration['extension']);
                $request->setControllerName($configuration['controller']);
                $request->setControllerActionName($configuration['action']);
-
+               $request->setArguments($arguments);
                $response = t3lib_div::makeInstance('TX_EXTMVC_Web_Response');
 
                $controllerObjectName = $request->getControllerObjectName();