public function addRule($attribute, $rule, $name = null) { $this->_rules[$attribute] = $rule; if ($name !== null) { $this->_attributes[$attribute] = $name; } return $this; }