original_string: public function validate($rule = null)
      {
          if (is_null($rule)) {
              throw $this->exception('Incorrect usage of field validation');
          }
  
          if (is_string($rule)) {
              // If string is passed, prefix with the field name
              $rule = $this->short_name.'|'.$rule;
          } elseif (is_array($rule)) {
              // if array is passed, prepend with the rule
              array_unshift($rule, $this->short_name);
              $rule = array($rule);
          } elseif (is_callable($rule)) {
              // callable or something else is passed. Wrap into array.
              $rule = array(array($this->short_name, $rule));
          }
  
          $this->form->validate($rule);
  
          return $this;
      }
code: public function validate($rule = null)
      {
          if (is_null($rule)) {
              throw $this->exception('Incorrect usage of field validation');
          }
  
          if (is_string($rule)) {
              // If string is passed, prefix with the field name
              $rule = $this->short_name.'|'.$rule;
          } elseif (is_array($rule)) {
              // if array is passed, prepend with the rule
              array_unshift($rule, $this->short_name);
              $rule = array($rule);
          } elseif (is_callable($rule)) {
              // callable or something else is passed. Wrap into array.
              $rule = array(array($this->short_name, $rule));
          }
  
          $this->form->validate($rule);
  
          return $this;
      }
code_tokens: public function validate ( $ rule = null ) { if ( is_null ( $ rule ) ) { throw $ this -> exception ( 'Incorrect usage of field validation' ) ; } if ( is_string ( $ rule ) ) { // If string is passed, prefix with the field name $ rule = $ this -> short_name . '|' . $ rule ; } elseif ( is_array ( $ rule ) ) { // if array is passed, prepend with the rule array_unshift ( $ rule , $ this -> short_name ) ; $ rule = array ( $ rule ) ; } elseif ( is_callable ( $ rule ) ) { // callable or something else is passed. Wrap into array. $ rule = array ( array ( $ this -> short_name , $ rule ) ) ; } $ this -> form -> validate ( $ rule ) ; return $ this ; }
docstring: This method has been refactored to integrate with Controller_Validator.
docstring_tokens: This method has been refactored to integrate with Controller_Validator .