original_string: protected function validateCodeLanguage()
      {
          $field = 'code';
  
          if ($this->isExcluded($field)) {
              return null;
          }
  
          $value = $this->getSubmitted($field);
  
          if ($this->isUpdating() && !isset($value)) {
              $this->unsetSubmitted($field);
              return null;
          }
  
          $label = $this->translation->text('Code');
  
          if (empty($value)) {
              $this->setErrorRequired($field, $label);
              return false;
          }
  
          if (preg_match('/^[A-Za-z\\-]+$/', $value) !== 1) {
              $this->setErrorInvalid($field, $label);
              return false;
          }
  
          $updating = $this->getUpdating();
  
          if (isset($updating['code']) && $updating['code'] === $value) {
              return true;
          }
  
          $language = $this->language->get($value);
  
          if (!empty($language)) {
              $this->setErrorExists($field, $label);
              return false;
          }
  
          return true;
      }
code: protected function validateCodeLanguage()
      {
          $field = 'code';
  
          if ($this->isExcluded($field)) {
              return null;
          }
  
          $value = $this->getSubmitted($field);
  
          if ($this->isUpdating() && !isset($value)) {
              $this->unsetSubmitted($field);
              return null;
          }
  
          $label = $this->translation->text('Code');
  
          if (empty($value)) {
              $this->setErrorRequired($field, $label);
              return false;
          }
  
          if (preg_match('/^[A-Za-z\\-]+$/', $value) !== 1) {
              $this->setErrorInvalid($field, $label);
              return false;
          }
  
          $updating = $this->getUpdating();
  
          if (isset($updating['code']) && $updating['code'] === $value) {
              return true;
          }
  
          $language = $this->language->get($value);
  
          if (!empty($language)) {
              $this->setErrorExists($field, $label);
              return false;
          }
  
          return true;
      }
code_tokens: protected function validateCodeLanguage ( ) { $ field = 'code' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isUpdating ( ) && ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ label = $ this -> translation -> text ( 'Code' ) ; if ( empty ( $ value ) ) { $ this -> setErrorRequired ( $ field , $ label ) ; return false ; } if ( preg_match ( '/^[A-Za-z\\-]+$/' , $ value ) !== 1 ) { $ this -> setErrorInvalid ( $ field , $ label ) ; return false ; } $ updating = $ this -> getUpdating ( ) ; if ( isset ( $ updating [ 'code' ] ) && $ updating [ 'code' ] === $ value ) { return true ; } $ language = $ this -> language -> get ( $ value ) ; if ( ! empty ( $ language ) ) { $ this -> setErrorExists ( $ field , $ label ) ; return false ; } return true ; }
docstring: Validates a language code
  @return boolean|null
docstring_tokens: Validates a language code