original_string: protected function validateCodePriceRule()
      {
          $field = 'code';
          $value = $this->getSubmitted($field);
  
          if (empty($value)) {
              return null;
          }
  
          $updating = $this->getUpdating();
  
          if (isset($updating['code']) && $updating['code'] === $value) {
              return true;
          }
  
          $label = $this->translation->text('Code');
  
          if (mb_strlen($value) > 255) {
              $this->setErrorLengthRange($field, $label, 0, 255);
              return false;
          }
  
          $rules = $this->price_rule->getList(array('code' => $value));
  
          if (empty($rules)) {
              return true;
          }
  
          foreach ((array) $rules as $rule) {
              if ($rule['code'] === $value) {
                  $this->setErrorExists($field, $label);
                  return false;
              }
          }
  
          return true;
      }
code: protected function validateCodePriceRule()
      {
          $field = 'code';
          $value = $this->getSubmitted($field);
  
          if (empty($value)) {
              return null;
          }
  
          $updating = $this->getUpdating();
  
          if (isset($updating['code']) && $updating['code'] === $value) {
              return true;
          }
  
          $label = $this->translation->text('Code');
  
          if (mb_strlen($value) > 255) {
              $this->setErrorLengthRange($field, $label, 0, 255);
              return false;
          }
  
          $rules = $this->price_rule->getList(array('code' => $value));
  
          if (empty($rules)) {
              return true;
          }
  
          foreach ((array) $rules as $rule) {
              if ($rule['code'] === $value) {
                  $this->setErrorExists($field, $label);
                  return false;
              }
          }
  
          return true;
      }
code_tokens: protected function validateCodePriceRule ( ) { $ field = 'code' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( empty ( $ value ) ) { return null ; } $ updating = $ this -> getUpdating ( ) ; if ( isset ( $ updating [ 'code' ] ) && $ updating [ 'code' ] === $ value ) { return true ; } $ label = $ this -> translation -> text ( 'Code' ) ; if ( mb_strlen ( $ value ) > 255 ) { $ this -> setErrorLengthRange ( $ field , $ label , 0 , 255 ) ; return false ; } $ rules = $ this -> price_rule -> getList ( array ( 'code' => $ value ) ) ; if ( empty ( $ rules ) ) { return true ; } foreach ( ( array ) $ rules as $ rule ) { if ( $ rule [ 'code' ] === $ value ) { $ this -> setErrorExists ( $ field , $ label ) ; return false ; } } return true ; }
docstring: Validates a price rule code
  @return boolean|null
docstring_tokens: Validates a price rule code