Commit 3a3245ab authored by Tino Goratsch's avatar Tino Goratsch

minor improvement

parent 3ef77306
......@@ -56,12 +56,10 @@ class Validator
*/
public function addConstraint($validationRuleName, array $params)
{
$key = serialize([
$this->constraints[] = [
'rule' => $validationRuleName,
$params
]);
$this->constraints[$key] = array_merge($this->getDefaultConstraintParams(), $params);
'params' => array_merge($this->getDefaultConstraintParams(), $params)
];
return $this;
}
......@@ -87,10 +85,10 @@ class Validator
{
$this->errors = [];
foreach ($this->constraints as $key => $params) {
$key = unserialize($key);
if (isset($this->validationRules[$key['rule']])) {
$validationRule = $this->validationRules[$key['rule']];
foreach ($this->constraints as $constraint) {
if (isset($this->validationRules[$constraint['rule']])) {
$validationRule = $this->validationRules[$constraint['rule']];
$params = $constraint['params'];
if (!empty($params['message'])) {
$validationRule->setMessage($params['message']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment