original_string: public function add($field, $name, $rule = [])
      {
          $validationSet = $this->field($field);
  
          if (!is_array($name)) {
              $rules = [$name => $rule];
          } else {
              $rules = $name;
          }
  
          foreach ($rules as $name => $rule) {
              if (is_array($rule)) {
                  $rule += ['rule' => $name];
              }
              $validationSet->add($name, $rule);
          }
  
          return $this;
      }
code: public function add($field, $name, $rule = [])
      {
          $validationSet = $this->field($field);
  
          if (!is_array($name)) {
              $rules = [$name => $rule];
          } else {
              $rules = $name;
          }
  
          foreach ($rules as $name => $rule) {
              if (is_array($rule)) {
                  $rule += ['rule' => $name];
              }
              $validationSet->add($name, $rule);
          }
  
          return $this;
      }
code_tokens: public function add ( $ field , $ name , $ rule = [ ] ) { $ validationSet = $ this -> field ( $ field ) ; if ( ! is_array ( $ name ) ) { $ rules = [ $ name => $ rule ] ; } else { $ rules = $ name ; } foreach ( $ rules as $ name => $ rule ) { if ( is_array ( $ rule ) ) { $ rule += [ 'rule' => $ name ] ; } $ validationSet -> add ( $ name , $ rule ) ; } return $ this ; }
docstring: Adds a new rule to a field's rule set. If second argument is an array
  then rules list for the field will be replaced with second argument and
  third argument will be ignored.
  
  ### Example:
  
  ```
  $validator
  ->add('title', 'required', ['rule' => 'notBlank'])
  ->add('user_id', 'valid', ['rule' => 'numeric', 'message' => 'Invalid User'])
  
  $validator->add('password', [
  'size' => ['rule' => ['lengthBetween', 8, 20]],
  'hasSpecialCharacter' => ['rule' => 'validateSpecialchar', 'message' => 'not valid']
  ]);
  ```
  
  @param string $field The name of the field from which the rule will be added
  @param array|string $name The alias for a single rule or multiple rules array
  @param array|\Cake\Validation\ValidationRule $rule the rule to add
  @return $this
docstring_tokens: Adds a new rule to a field s rule set . If second argument is an array then rules list for the field will be replaced with second argument and third argument will be ignored .