original_string: protected function validateStateAddress()
      {
          $field = 'state_id';
          $value = $this->getSubmitted($field);
  
          if (!isset($value)) {
              $this->unsetSubmitted($field);
              return null;
          }
  
          $label = $this->translation->text('Country state');
          $format = $this->getCountryFormatAddress();
  
          if (empty($value) && !empty($format['state_id']['required'])) {
              $this->setErrorRequired($field, $label);
              return false;
          }
  
          if (!is_numeric($value)) {
              $this->setErrorNumeric($field, $label);
              return false;
          }
  
          if (empty($value)) {
              return true;
          }
  
          $state = $this->state->get($value);
  
          if (empty($state)) {
              $this->setErrorUnavailable($field, $label);
              return false;
          }
  
          return true;
      }
code: protected function validateStateAddress()
      {
          $field = 'state_id';
          $value = $this->getSubmitted($field);
  
          if (!isset($value)) {
              $this->unsetSubmitted($field);
              return null;
          }
  
          $label = $this->translation->text('Country state');
          $format = $this->getCountryFormatAddress();
  
          if (empty($value) && !empty($format['state_id']['required'])) {
              $this->setErrorRequired($field, $label);
              return false;
          }
  
          if (!is_numeric($value)) {
              $this->setErrorNumeric($field, $label);
              return false;
          }
  
          if (empty($value)) {
              return true;
          }
  
          $state = $this->state->get($value);
  
          if (empty($state)) {
              $this->setErrorUnavailable($field, $label);
              return false;
          }
  
          return true;
      }
code_tokens: protected function validateStateAddress ( ) { $ field = 'state_id' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ label = $ this -> translation -> text ( 'Country state' ) ; $ format = $ this -> getCountryFormatAddress ( ) ; if ( empty ( $ value ) && ! empty ( $ format [ 'state_id' ] [ 'required' ] ) ) { $ this -> setErrorRequired ( $ field , $ label ) ; return false ; } if ( ! is_numeric ( $ value ) ) { $ this -> setErrorNumeric ( $ field , $ label ) ; return false ; } if ( empty ( $ value ) ) { return true ; } $ state = $ this -> state -> get ( $ value ) ; if ( empty ( $ state ) ) { $ this -> setErrorUnavailable ( $ field , $ label ) ; return false ; } return true ; }
docstring: Validates a country state
  @return boolean|null
docstring_tokens: Validates a country state