[TASK] Do not copy validation code, call to parent method instead
authorOliver Eglseder <oliver.eglseder@in2code.de>
Thu, 10 Sep 2015 11:04:45 +0000 (13:04 +0200)
committerOliver Eglseder <oliver.eglseder@in2code.de>
Thu, 10 Sep 2015 11:04:45 +0000 (13:04 +0200)
Classes/Domain/Validator/ConditionAwareValidator.php

index 297b95c..14d660a 100644 (file)
@@ -81,116 +81,6 @@ class ConditionAwareValidator extends InputValidator {
                                }
                        }
                }
-
-               // Mandatory Check
-               if ($field->getMandatory()) {
-                       if (!$this->validateMandatory($value)) {
-                               $this->setErrorAndMessage($field, 'mandatory');
-                       }
-               }
-
-               // String Checks
-               if (!empty($value) && in_array($field->getType(), $this->validationFieldTypes)) {
-                       switch ($field->getValidation()) {
-
-                               // email
-                               case 1:
-                                       if (!$this->validateEmail($value)) {
-                                               $this->setErrorAndMessage($field, 'validation.' . $field->getValidation());
-                                       }
-                                       break;
-
-                               // URL
-                               case 2:
-                                       if (!$this->validateUrl($value)) {
-                                               $this->setErrorAndMessage($field, 'validation.' . $field->getValidation());
-                                       }
-                                       break;
-
-                               // phone
-                               case 3:
-                                       if (!$this->validatePhone($value)) {
-                                               $this->setErrorAndMessage($field, 'validation.' . $field->getValidation());
-                                       }
-                                       break;
-
-                               // numbers only
-                               case 4:
-                                       if (!$this->validateNumbersOnly($value)) {
-                                               $this->setErrorAndMessage($field, 'validation.' . $field->getValidation());
-                                       }
-                                       break;
-
-                               // letters only
-                               case 5:
-                                       if (!$this->validateLettersOnly($value)) {
-                                               $this->setErrorAndMessage($field, 'validation.' . $field->getValidation());
-                                       }
-                                       break;
-
-                               // min number
-                               case 6:
-                                       if (!$this->validateMinNumber($value, $field->getValidationConfiguration())) {
-                                               $this->setErrorAndMessage($field, 'validation.' . $field->getValidation());
-                                       }
-                                       break;
-
-                               // max number
-                               case 7:
-                                       if (!$this->validateMaxNumber($value, $field->getValidationConfiguration())) {
-                                               $this->setErrorAndMessage($field, 'validation.' . $field->getValidation());
-                                       }
-                                       break;
-
-                               // range
-                               case 8:
-                                       if (!$this->validateRange($value, $field->getValidationConfiguration())) {
-                                               $this->setErrorAndMessage($field, 'validation.' . $field->getValidation());
-                                       }
-                                       break;
-
-                               // length
-                               case 9:
-                                       if (!$this->validateLength($value, $field->getValidationConfiguration())) {
-                                               $this->setErrorAndMessage($field, 'validation.' . $field->getValidation());
-                                       }
-                                       break;
-
-                               // pattern
-                               case 10:
-                                       if (!$this->validatePattern($value, $field->getValidationConfiguration())) {
-                                               $this->setErrorAndMessage($field, 'validation.' . $field->getValidation());
-                                       }
-                                       break;
-
-                               /**
-                                * E.g. Validation was extended with Page TSconfig
-                                *              tx_powermail.flexForm.validation.addFieldOptions.100 = New Validation
-                                *
-                                * Register your Class and Method with TypoScript Setup
-                                *              plugin.tx_powermail.settings.setup.validation.customValidation.100 =
-                                *                      In2code\Powermailextended\Domain\Validator\ZipValidator
-                                *
-                                * Add method to your class
-                                *              validate100($value, $validationConfiguration)
-                                *
-                                * Define your Errormessage with TypoScript Setup
-                                *              plugin.tx_powermail._LOCAL_LANG.default.validationerror_validation.100 =
-                                *                      Error happens!
-                                */
-                               default:
-                                       if ($field->getValidation()) {
-                                               $validation = $field->getValidation();
-                                               if (!empty($this->settings['validation.']['customValidation.'][$validation])) {
-                                                       $extendedValidator = $this->objectManager->get($this->settings['validation.']['customValidation.'][$validation]);
-                                                       if (method_exists($extendedValidator, 'validate' . ucfirst($validation))) {
-                                                               if (!$extendedValidator->{'validate' . ucfirst($validation)}($value, $field->getValidationConfiguration())) {
-                                                                       $this->setErrorAndMessage($field, 'validation.' . $validation);
-                                                               }
-                                                       }
-                                               }
-                                       }
-                       }
-               }
+               parent::isValidField($field, $value);
        }
 }