original_string: protected function validateCodeCurrency()
      {
          $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]{3}$/', $value) !== 1) {
              $this->setErrorInvalid($field, $label);
              return false;
          }
  
          $code = strtoupper($value);
          $updating = $this->getUpdating();
  
          if (isset($updating['code']) && $updating['code'] === $code) {
              return true;
          }
  
          $existing = $this->currency->get($code);
  
          if (!empty($existing)) {
              $this->setErrorExists($field, $label);
              return false;
          }
  
          $this->setSubmitted($field, $code);
          return true;
      }
code: protected function validateCodeCurrency()
      {
          $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]{3}$/', $value) !== 1) {
              $this->setErrorInvalid($field, $label);
              return false;
          }
  
          $code = strtoupper($value);
          $updating = $this->getUpdating();
  
          if (isset($updating['code']) && $updating['code'] === $code) {
              return true;
          }
  
          $existing = $this->currency->get($code);
  
          if (!empty($existing)) {
              $this->setErrorExists($field, $label);
              return false;
          }
  
          $this->setSubmitted($field, $code);
          return true;
      }
code_tokens: protected function validateCodeCurrency ( ) { $ 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]{3}$/' , $ value ) !== 1 ) { $ this -> setErrorInvalid ( $ field , $ label ) ; return false ; } $ code = strtoupper ( $ value ) ; $ updating = $ this -> getUpdating ( ) ; if ( isset ( $ updating [ 'code' ] ) && $ updating [ 'code' ] === $ code ) { return true ; } $ existing = $ this -> currency -> get ( $ code ) ; if ( ! empty ( $ existing ) ) { $ this -> setErrorExists ( $ field , $ label ) ; return false ; } $ this -> setSubmitted ( $ field , $ code ) ; return true ; }
docstring: Validates currency code
  @return boolean|null
docstring_tokens: Validates currency code