/** * Adds a new rule for a given property or key name. * @param string $name The name of the key or property. * @param Validator $rule The validation rule. * @param string $label The label to be shown in the error message (intead of the name). */ public function addRule($name, $rule, $label = null) { if ($label === null) { $label = $name; } $rule->addKeyValue('key', $label); $this->validators[$name][] = $rule; $this->updateSingleKeyValue($rule); }
/** * Applies the template message to a formed one. * @return string The formed message. */ protected function applyTemplate() { $i = 1; foreach ($this->validators as $v) { $this->addKeyValue('v' . $i++, $v->getErrorMessage()); } return parent::applyTemplate(); }