code: public function addRule($attributes, $validator, $options = [])
      {
          $validators = $this->getValidators();
          $validators->append(Validator::createValidator($validator, $this, (array)$attributes, $options));
  
          return $this;
      }
docs: Adds a validation rule to this model.
  You can also directly manipulate [[validators]] to add or remove validation rules.
  This method provides a shortcut.
  @param string|array $attributes the attribute(s) to be validated by the rule
  @param mixed $validator the validator for the rule.This can be a built-in validator name,
  a method name of the model class, an anonymous function, or a validator class name.
  @param array $options the options (name-value pairs) to be applied to the validator
  @return $this the model itself