protected function _applyMessages(Model $model, array $rules) {
        foreach ($rules as $key => $value) {
            if (is_array($value)) {
                if ($key !== 'rule') {
                    $rules[$key] = $this->_applyMessages($model, $value);
                }

            // Collapsed rules
            } else if (isset($this->_messages[$value]) && $key !== 'rule') {
                $rules[$key] = array(
                    $value => array(
                        'rule' => $value,
                        'message' => $this->_messages[$value]
                    )
                );

            // Missing message
            } else if ($key === 'rule') {
                $rule = $value;

                if (is_array($rule)) {
                    $rule = array_shift($params);
                }

                if (isset($this->_messages[$rule]) && empty($rules['message'])) {
                    $rules['message'] = $this->_messages[$rule];
                }
            }
        }

        return $rules;
    }