/**
  * Set different validation attributes
  *
  * @param array &$additionalAttributes
  * @param Field $field
  * @return void
  */
 protected function addValidationAttributes(&$additionalAttributes, $field)
 {
     if ($field->getType() !== 'input' && $field->getType() !== 'textarea') {
         return;
     }
     switch ($field->getValidation()) {
         /**
          * EMAIL (+html5)
          *
          * html5 example: <input type="email" />
          * javascript example: <input type="text" data-parsley-type="email" />
          */
         case 1:
             if ($this->isClientValidationEnabled() && !$this->isNativeValidationEnabled()) {
                 $additionalAttributes['data-parsley-type'] = 'email';
             }
             break;
             /**
              * URL (+html5)
              *
              * html5 example: <input type="url" />
              * javascript example: <input type="text" data-parsley-type="url" />
              */
         /**
          * URL (+html5)
          *
          * html5 example: <input type="url" />
          * javascript example: <input type="text" data-parsley-type="url" />
          */
         case 2:
             if ($this->isClientValidationEnabled() && !$this->isNativeValidationEnabled()) {
                 $additionalAttributes['data-parsley-type'] = 'url';
             }
             break;
             /**
              * PHONE (+html5)
              *        01234567890
              *        0123 4567890
              *        0123 456 789
              *        (0123) 45678 - 90
              *        0012 345 678 9012
              *        0012 (0)345 / 67890 - 12
              *        +123456789012
              *        +12 345 678 9012
              *        +12 3456 7890123
              *        +49 (0) 123 3456789
              *        +49 (0)123 / 34567 - 89
              *
              * html5 example:
              *        <input type="text"
              *            pattern="/^(\+\d{1,4}|0+\d{1,5}|\(\d{1,5})[\d\s\/\(\)-]*\d+$/" />
              * javascript example:
              *        <input ... data-parsley-pattern=
              *            "/^(\+\d{1,4}|0+\d{1,5}|\(\d{1,5})[\d\s\/\(\)-]*\d+$/" />
              */
         /**
          * PHONE (+html5)
          *        01234567890
          *        0123 4567890
          *        0123 456 789
          *        (0123) 45678 - 90
          *        0012 345 678 9012
          *        0012 (0)345 / 67890 - 12
          *        +123456789012
          *        +12 345 678 9012
          *        +12 3456 7890123
          *        +49 (0) 123 3456789
          *        +49 (0)123 / 34567 - 89
          *
          * html5 example:
          *        <input type="text"
          *            pattern="/^(\+\d{1,4}|0+\d{1,5}|\(\d{1,5})[\d\s\/\(\)-]*\d+$/" />
          * javascript example:
          *        <input ... data-parsley-pattern=
          *            "/^(\+\d{1,4}|0+\d{1,5}|\(\d{1,5})[\d\s\/\(\)-]*\d+$/" />
          */
         case 3:
             $pattern = '^(\\+\\d{1,4}|0+\\d{1,5}|\\(\\d{1,5})[\\d\\s\\/\\(\\)-]*\\d+$';
             if ($this->isNativeValidationEnabled()) {
                 $additionalAttributes['pattern'] = $pattern;
             } else {
                 if ($this->isClientValidationEnabled()) {
                     $additionalAttributes['data-parsley-pattern'] = $pattern;
                 }
             }
             break;
             /**
              * NUMBER/INTEGER (+html5)
              *
              * html5 example: <input type="number" />
              * javascript example: <input type="text" data-parsley-type="integer" />
              */
         /**
          * NUMBER/INTEGER (+html5)
          *
          * html5 example: <input type="number" />
          * javascript example: <input type="text" data-parsley-type="integer" />
          */
         case 4:
             if ($this->isClientValidationEnabled() && !$this->isNativeValidationEnabled()) {
                 $additionalAttributes['data-parsley-type'] = 'integer';
             }
             break;
             /**
              * LETTERS (+html5)
              *
              * html5 example: <input type="text" pattern="[a-zA-Z]." />
              * javascript example: <input type="text" data-parsley-pattern="[a-zA-Z]." />
              */
         /**
          * LETTERS (+html5)
          *
          * html5 example: <input type="text" pattern="[a-zA-Z]." />
          * javascript example: <input type="text" data-parsley-pattern="[a-zA-Z]." />
          */
         case 5:
             if ($this->isNativeValidationEnabled()) {
                 $additionalAttributes['pattern'] = '[A-Za-z]+';
             } else {
                 if ($this->isClientValidationEnabled()) {
                     $additionalAttributes['data-parsley-pattern'] = '[a-zA-Z]+';
                 }
             }
             break;
             /**
              * MIN NUMBER (+html5)
              *
              * Note: Field validation_configuration for editors viewable
              * html5 example: <input type="text" min="6" />
              * javascript example: <input type="text" data-parsley-min="6" />
              */
         /**
          * MIN NUMBER (+html5)
          *
          * Note: Field validation_configuration for editors viewable
          * html5 example: <input type="text" min="6" />
          * javascript example: <input type="text" data-parsley-min="6" />
          */
         case 6:
             if ($this->isNativeValidationEnabled()) {
                 $additionalAttributes['min'] = $field->getValidationConfiguration();
             } else {
                 if ($this->isClientValidationEnabled()) {
                     $additionalAttributes['data-parsley-min'] = $field->getValidationConfiguration();
                 }
             }
             break;
             /**
              * MAX NUMBER (+html5)
              *
              * Note: Field validation_configuration for editors viewable
              * html5 example: <input type="text" max="12" />
              * javascript example: <input type="text" data-parsley-max="12" />
              */
         /**
          * MAX NUMBER (+html5)
          *
          * Note: Field validation_configuration for editors viewable
          * html5 example: <input type="text" max="12" />
          * javascript example: <input type="text" data-parsley-max="12" />
          */
         case 7:
             if ($this->isNativeValidationEnabled()) {
                 $additionalAttributes['max'] = $field->getValidationConfiguration();
             } else {
                 if ($this->isClientValidationEnabled()) {
                     $additionalAttributes['data-parsley-max'] = $field->getValidationConfiguration();
                 }
             }
             break;
             /**
              * RANGE (+html5)
              *
              * Note: Field validation_configuration for editors viewable
              * html5 example: <input type="range" min="1" max="10" />
              * javascript example:
              *        <input type="text" data-parsley-type="range" min="1" max="10" />
              */
         /**
          * RANGE (+html5)
          *
          * Note: Field validation_configuration for editors viewable
          * html5 example: <input type="range" min="1" max="10" />
          * javascript example:
          *        <input type="text" data-parsley-type="range" min="1" max="10" />
          */
         case 8:
             $values = GeneralUtility::trimExplode(',', $field->getValidationConfiguration(), true);
             if ((int) $values[0] <= 0) {
                 break;
             }
             if (!isset($values[1])) {
                 $values[1] = $values[0];
                 $values[0] = 1;
             }
             if ($this->isNativeValidationEnabled()) {
                 $additionalAttributes['min'] = (int) $values[0];
                 $additionalAttributes['max'] = (int) $values[1];
             } else {
                 if ($this->isClientValidationEnabled()) {
                     $additionalAttributes['data-parsley-min'] = (int) $values[0];
                     $additionalAttributes['data-parsley-max'] = (int) $values[1];
                 }
             }
             break;
             /**
              * LENGTH
              *
              * Note: Field validation_configuration for editors viewable
              * javascript example:
              *        <input type="text" data-parsley-length="[6, 10]" />
              */
         /**
          * LENGTH
          *
          * Note: Field validation_configuration for editors viewable
          * javascript example:
          *        <input type="text" data-parsley-length="[6, 10]" />
          */
         case 9:
             $values = GeneralUtility::trimExplode(',', $field->getValidationConfiguration(), true);
             if ((int) $values[0] <= 0) {
                 break;
             }
             if (!isset($values[1])) {
                 $values[1] = (int) $values[0];
                 $values[0] = 1;
             }
             if ($this->isClientValidationEnabled()) {
                 $additionalAttributes['data-parsley-length'] = '[' . implode(', ', $values) . ']';
             }
             break;
             /**
              * PATTERN (+html5)
              *
              * Note: Field validation_configuration for editors viewable
              * html5 example: <input type="text" pattern="https?://.+" />
              * javascript example:
              *        <input type="text" data-parsley-pattern="https?://.+" />
              */
         /**
          * PATTERN (+html5)
          *
          * Note: Field validation_configuration for editors viewable
          * html5 example: <input type="text" pattern="https?://.+" />
          * javascript example:
          *        <input type="text" data-parsley-pattern="https?://.+" />
          */
         case 10:
             if ($this->isNativeValidationEnabled()) {
                 $additionalAttributes['pattern'] = $field->getValidationConfiguration();
             } else {
                 if ($this->isClientValidationEnabled()) {
                     $additionalAttributes['data-parsley-pattern'] = $field->getValidationConfiguration();
                 }
             }
             break;
             /**
              * Custom Validation Attribute
              *
              * If CustomValidation was added via Page TSConfig
              *        tx_powermail.flexForm.validation.addFieldOptions.100 = New Validation
              *
              * <input type="text" data-parsley-custom100="1" />
              */
         /**
          * Custom Validation Attribute
          *
          * If CustomValidation was added via Page TSConfig
          *        tx_powermail.flexForm.validation.addFieldOptions.100 = New Validation
          *
          * <input type="text" data-parsley-custom100="1" />
          */
         default:
             if ($field->getValidation() && $this->isClientValidationEnabled()) {
                 $value = 1;
                 if ($field->getValidationConfiguration()) {
                     $value = $field->getValidationConfiguration();
                 }
                 $additionalAttributes['data-parsley-custom' . $field->getValidation()] = $value;
             }
     }
     // set errormessage if javascript validation active
     if ($field->getValidation() && $this->isClientValidationEnabled()) {
         $additionalAttributes['data-parsley-error-message'] = LocalizationUtility::translate('validationerror_validation.' . $field->getValidation());
     }
 }
 /**
  * Set different validation attributes
  *
  * @param \array $dataArray
  * @param \In2code\Powermail\Domain\Model\Field $field
  * @return void
  */
 protected function addValidationAttributes(&$dataArray, $field)
 {
     if ($field->getType() !== 'input' && $field->getType() !== 'textarea') {
         return;
     }
     switch ($field->getValidation()) {
         /**
          * EMAIL (+html5)
          *
          * html5 example: <input type="email" />
          * javascript example: <input type="text" data-parsley-type="email" />
          */
         case 1:
             if ($this->isClientValidationEnabled() && !$this->isNativeValidationEnabled()) {
                 $dataArray['data-parsley-type'] = 'email';
             }
             break;
             /**
              * URL (+html5)
              *
              * html5 example: <input type="url" />
              * javascript example: <input type="text" data-parsley-type="url" />
              */
         /**
          * URL (+html5)
          *
          * html5 example: <input type="url" />
          * javascript example: <input type="text" data-parsley-type="url" />
          */
         case 2:
             if ($this->isClientValidationEnabled() && !$this->isNativeValidationEnabled()) {
                 $dataArray['data-parsley-type'] = 'url';
             }
             break;
             /**
              * PHONE (+html5)
              * 		0 123 456 7890
              * 		0123 4567890
              * 		01234567890
              * 		+12 345 6789012
              * 		+12 345 678 9012
              *
              * html5 example:
              * 		<input type="text" pattern="((\+[\d]{2}|0)\s[\d]{3,}\s[\d\s]+|[0-9 ]+)" />
              * javascript example:
              * 		<input ... data-parsley-pattern="((\+[\d]{2}|0)\s[\d]{3,}\s[\d\s]+|[0-9 ]+)" />
              */
         /**
          * PHONE (+html5)
          * 		0 123 456 7890
          * 		0123 4567890
          * 		01234567890
          * 		+12 345 6789012
          * 		+12 345 678 9012
          *
          * html5 example:
          * 		<input type="text" pattern="((\+[\d]{2}|0)\s[\d]{3,}\s[\d\s]+|[0-9 ]+)" />
          * javascript example:
          * 		<input ... data-parsley-pattern="((\+[\d]{2}|0)\s[\d]{3,}\s[\d\s]+|[0-9 ]+)" />
          */
         case 3:
             if ($this->isNativeValidationEnabled()) {
                 $dataArray['pattern'] = '((\\+[\\d]{2}|0)\\s[\\d]{3,}\\s[\\d\\s]+|[0-9 ]+)';
             } else {
                 if ($this->isClientValidationEnabled()) {
                     $dataArray['data-parsley-pattern'] = '((\\+[\\d]{2}|0)\\s[\\d]{3,}\\s[\\d\\s]+|[0-9 ]+)';
                 }
             }
             break;
             /**
              * NUMBER/INTEGER (+html5)
              *
              * html5 example: <input type="number" />
              * javascript example: <input type="text" data-parsley-type="integer" />
              */
         /**
          * NUMBER/INTEGER (+html5)
          *
          * html5 example: <input type="number" />
          * javascript example: <input type="text" data-parsley-type="integer" />
          */
         case 4:
             if ($this->isClientValidationEnabled() && !$this->isNativeValidationEnabled()) {
                 $dataArray['data-parsley-type'] = 'integer';
             }
             break;
             /**
              * LETTERS (+html5)
              *
              * html5 example: <input type="text" pattern="[a-zA-Z]." />
              * javascript example: <input type="text" data-parsley-pattern="[a-zA-Z]." />
              */
         /**
          * LETTERS (+html5)
          *
          * html5 example: <input type="text" pattern="[a-zA-Z]." />
          * javascript example: <input type="text" data-parsley-pattern="[a-zA-Z]." />
          */
         case 5:
             if ($this->isNativeValidationEnabled()) {
                 $dataArray['pattern'] = '[A-Za-z].';
             } else {
                 if ($this->isClientValidationEnabled()) {
                     $dataArray['data-parsley-pattern'] = '[a-zA-Z].';
                 }
             }
             break;
             /**
              * MIN NUMBER (+html5)
              *
              * Note: Field validation_configuration for editors viewable
              * html5 example: <input type="text" min="6" />
              * javascript example: <input type="text" data-parsley-min="6" />
              */
         /**
          * MIN NUMBER (+html5)
          *
          * Note: Field validation_configuration for editors viewable
          * html5 example: <input type="text" min="6" />
          * javascript example: <input type="text" data-parsley-min="6" />
          */
         case 6:
             if ($this->isNativeValidationEnabled()) {
                 $dataArray['min'] = $field->getValidationConfiguration();
             } else {
                 if ($this->isClientValidationEnabled()) {
                     $dataArray['data-parsley-min'] = $field->getValidationConfiguration();
                 }
             }
             break;
             /**
              * MAX NUMBER (+html5)
              *
              * Note: Field validation_configuration for editors viewable
              * html5 example: <input type="text" max="12" />
              * javascript example: <input type="text" data-parsley-max="12" />
              */
         /**
          * MAX NUMBER (+html5)
          *
          * Note: Field validation_configuration for editors viewable
          * html5 example: <input type="text" max="12" />
          * javascript example: <input type="text" data-parsley-max="12" />
          */
         case 7:
             if ($this->isNativeValidationEnabled()) {
                 $dataArray['max'] = $field->getValidationConfiguration();
             } else {
                 if ($this->isClientValidationEnabled()) {
                     $dataArray['data-parsley-max'] = $field->getValidationConfiguration();
                 }
             }
             break;
             /**
              * RANGE (+html5)
              *
              * Note: Field validation_configuration for editors viewable
              * html5 example: <input type="range" min="1" max="10" />
              * javascript example:
              * 		<input type="text" data-parsley-type="range" min="1" max="10" />
              */
         /**
          * RANGE (+html5)
          *
          * Note: Field validation_configuration for editors viewable
          * html5 example: <input type="range" min="1" max="10" />
          * javascript example:
          * 		<input type="text" data-parsley-type="range" min="1" max="10" />
          */
         case 8:
             $values = GeneralUtility::trimExplode(',', $field->getValidationConfiguration(), TRUE);
             if (intval($values[0]) <= 0) {
                 break;
             }
             if (!isset($values[1])) {
                 $values[1] = $values[0];
                 $values[0] = 1;
             }
             if ($this->isNativeValidationEnabled()) {
                 $dataArray['min'] = intval($values[0]);
                 $dataArray['max'] = intval($values[1]);
             } else {
                 if ($this->isClientValidationEnabled()) {
                     $dataArray['data-parsley-min'] = intval($values[0]);
                     $dataArray['data-parsley-max'] = intval($values[1]);
                 }
             }
             break;
             /**
              * LENGTH
              *
              * Note: Field validation_configuration for editors viewable
              * javascript example:
              * 		<input type="text" data-parsley-length="[6, 10]" />
              */
         /**
          * LENGTH
          *
          * Note: Field validation_configuration for editors viewable
          * javascript example:
          * 		<input type="text" data-parsley-length="[6, 10]" />
          */
         case 9:
             $values = GeneralUtility::trimExplode(',', $field->getValidationConfiguration(), TRUE);
             if (intval($values[0]) <= 0) {
                 break;
             }
             if (!isset($values[1])) {
                 $values[1] = intval($values[0]);
                 $values[0] = 1;
             }
             if ($this->isClientValidationEnabled()) {
                 $dataArray['data-parsley-length'] = '[' . implode(', ', $values) . ']';
             }
             break;
             /**
              * PATTERN (+html5)
              *
              * Note: Field validation_configuration for editors viewable
              * html5 example: <input type="text" pattern="https?://.+" />
              * javascript example:
              * 		<input type="text" data-parsley-pattern="https?://.+" />
              */
         /**
          * PATTERN (+html5)
          *
          * Note: Field validation_configuration for editors viewable
          * html5 example: <input type="text" pattern="https?://.+" />
          * javascript example:
          * 		<input type="text" data-parsley-pattern="https?://.+" />
          */
         case 10:
             if ($this->isNativeValidationEnabled()) {
                 $dataArray['pattern'] = $field->getValidationConfiguration();
             } else {
                 if ($this->isClientValidationEnabled()) {
                     $dataArray['data-parsley-pattern'] = $field->getValidationConfiguration();
                 }
             }
             break;
             /**
              * Custom Validation Attribute
              *
              * If CustomValidation was added via Page TSConfig
              * 		tx_powermail.flexForm.validation.addFieldOptions.100 = New Validation
              *
              * <input type="text" data-parsley-custom100="1" />
              */
         /**
          * Custom Validation Attribute
          *
          * If CustomValidation was added via Page TSConfig
          * 		tx_powermail.flexForm.validation.addFieldOptions.100 = New Validation
          *
          * <input type="text" data-parsley-custom100="1" />
          */
         default:
             if ($field->getValidation() && $this->isClientValidationEnabled()) {
                 $value = 1;
                 if ($field->getValidationConfiguration()) {
                     $value = $field->getValidationConfiguration();
                 }
                 $dataArray['data-parsley-custom' . $field->getValidation()] = $value;
             }
     }
     // set errormessage if javascript validation active
     if ($field->getValidation() && $this->isClientValidationEnabled()) {
         $dataArray['data-parsley-error-message'] = LocalizationUtility::translate('validationerror_validation.' . $field->getValidation(), $this->extensionName);
     }
 }