original_string: public function validation($data, $files) {
          $errors = parent::validation($data, $files);
  
          if (!array_key_exists('name', $errors)) {
              if (!preg_match('#^[a-zA-Z0-9\-_ ]+$#', $data['name'])) {
                  $errors['name'] = get_string('storenameinvalid', 'cache');
              } else if (empty($this->_customdata['store'])) {
                  $stores = cache_administration_helper::get_store_instance_summaries();
                  if (array_key_exists($data['name'], $stores)) {
                      $errors['name'] = get_string('storenamealreadyused', 'cache');
                  }
              }
          }
  
          if (method_exists($this, 'configuration_validation')) {
              $newerrors = $this->configuration_validation($data, $files, $errors);
              // We need to selectiviliy merge here
              foreach ($newerrors as $element => $error) {
                  if (!array_key_exists($element, $errors)) {
                      $errors[$element] = $error;
                  }
              }
          }
  
          return $errors;
      }
code: public function validation($data, $files) {
          $errors = parent::validation($data, $files);
  
          if (!array_key_exists('name', $errors)) {
              if (!preg_match('#^[a-zA-Z0-9\-_ ]+$#', $data['name'])) {
                  $errors['name'] = get_string('storenameinvalid', 'cache');
              } else if (empty($this->_customdata['store'])) {
                  $stores = cache_administration_helper::get_store_instance_summaries();
                  if (array_key_exists($data['name'], $stores)) {
                      $errors['name'] = get_string('storenamealreadyused', 'cache');
                  }
              }
          }
  
          if (method_exists($this, 'configuration_validation')) {
              $newerrors = $this->configuration_validation($data, $files, $errors);
              // We need to selectiviliy merge here
              foreach ($newerrors as $element => $error) {
                  if (!array_key_exists($element, $errors)) {
                      $errors[$element] = $error;
                  }
              }
          }
  
          return $errors;
      }
code_tokens: public function validation ( $ data , $ files ) { $ errors = parent :: validation ( $ data , $ files ) ; if ( ! array_key_exists ( 'name' , $ errors ) ) { if ( ! preg_match ( '#^[a-zA-Z0-9\-_ ]+$#' , $ data [ 'name' ] ) ) { $ errors [ 'name' ] = get_string ( 'storenameinvalid' , 'cache' ) ; } else if ( empty ( $ this -> _customdata [ 'store' ] ) ) { $ stores = cache_administration_helper :: get_store_instance_summaries ( ) ; if ( array_key_exists ( $ data [ 'name' ] , $ stores ) ) { $ errors [ 'name' ] = get_string ( 'storenamealreadyused' , 'cache' ) ; } } } if ( method_exists ( $ this , 'configuration_validation' ) ) { $ newerrors = $ this -> configuration_validation ( $ data , $ files , $ errors ) ; // We need to selectiviliy merge here foreach ( $ newerrors as $ element => $ error ) { if ( ! array_key_exists ( $ element , $ errors ) ) { $ errors [ $ element ] = $ error ; } } } return $ errors ; }
docstring: Validates the add instance form data
  
  @param array $data
  @param array $files
  @return array
docstring_tokens: Validates the add instance form data