original_string: public function validation($data, $files = array()) {
          global $DB;
  
          $errors = array();
          /** @var field_controller $field */
          $field = $this->_customdata['field'];
          $handler = $field->get_handler();
  
          // Check the shortname is specified and is unique for this component-area-itemid combination.
          if (!preg_match('/^[a-z0-9_]+$/', $data['shortname'])) {
              // Check allowed pattern (numbers, letters and underscore).
              $errors['shortname'] = get_string('invalidshortnameerror', 'core_customfield');
          } else if ($DB->record_exists_sql('SELECT 1 FROM {customfield_field} f ' .
              'JOIN {customfield_category} c ON c.id = f.categoryid ' .
              'WHERE f.shortname = ? AND f.id <> ? AND c.component = ? AND c.area = ? AND c.itemid = ?',
              [$data['shortname'], $data['id'],
                  $handler->get_component(), $handler->get_area(), $handler->get_itemid()])) {
              $errors['shortname'] = get_string('formfieldcheckshortname', 'core_customfield');
          }
  
          $errors = array_merge($errors, $field->config_form_validation($data, $files));
  
          return $errors;
      }
code: public function validation($data, $files = array()) {
          global $DB;
  
          $errors = array();
          /** @var field_controller $field */
          $field = $this->_customdata['field'];
          $handler = $field->get_handler();
  
          // Check the shortname is specified and is unique for this component-area-itemid combination.
          if (!preg_match('/^[a-z0-9_]+$/', $data['shortname'])) {
              // Check allowed pattern (numbers, letters and underscore).
              $errors['shortname'] = get_string('invalidshortnameerror', 'core_customfield');
          } else if ($DB->record_exists_sql('SELECT 1 FROM {customfield_field} f ' .
              'JOIN {customfield_category} c ON c.id = f.categoryid ' .
              'WHERE f.shortname = ? AND f.id <> ? AND c.component = ? AND c.area = ? AND c.itemid = ?',
              [$data['shortname'], $data['id'],
                  $handler->get_component(), $handler->get_area(), $handler->get_itemid()])) {
              $errors['shortname'] = get_string('formfieldcheckshortname', 'core_customfield');
          }
  
          $errors = array_merge($errors, $field->config_form_validation($data, $files));
  
          return $errors;
      }
code_tokens: public function validation ( $ data , $ files = array ( ) ) { global $ DB ; $ errors = array ( ) ; /** @var field_controller $field */ $ field = $ this -> _customdata [ 'field' ] ; $ handler = $ field -> get_handler ( ) ; // Check the shortname is specified and is unique for this component-area-itemid combination. if ( ! preg_match ( '/^[a-z0-9_]+$/' , $ data [ 'shortname' ] ) ) { // Check allowed pattern (numbers, letters and underscore). $ errors [ 'shortname' ] = get_string ( 'invalidshortnameerror' , 'core_customfield' ) ; } else if ( $ DB -> record_exists_sql ( 'SELECT 1 FROM {customfield_field} f ' . 'JOIN {customfield_category} c ON c.id = f.categoryid ' . 'WHERE f.shortname = ? AND f.id <> ? AND c.component = ? AND c.area = ? AND c.itemid = ?' , [ $ data [ 'shortname' ] , $ data [ 'id' ] , $ handler -> get_component ( ) , $ handler -> get_area ( ) , $ handler -> get_itemid ( ) ] ) ) { $ errors [ 'shortname' ] = get_string ( 'formfieldcheckshortname' , 'core_customfield' ) ; } $ errors = array_merge ( $ errors , $ field -> config_form_validation ( $ data , $ files ) ) ; return $ errors ; }
docstring: Field data validation
  
  @param array $data
  @param array $files
  @return array
docstring_tokens: Field data validation