public function getMessage() {
        if ($this->mainMessage) {
            return $this->mainMessage;
        }

        // Generate the message by concatenating all of the errors together.
        $messages = [];
        foreach ($this->errors as $errors) {
            foreach ($errors as $error) {
                $field = val('field', $error, '*');
                if (is_array($field)) {
                    $field = implode(', ', $field);
                }

                if (isset($error['message'])) {
                    $message = $error['message'];
                } elseif (strpos($error['code'], '%s') === false) {
                    $message = sprintft($error['code'].': %s.', $field);
                } else {
                    $message = sprintft($error['code'], $field);
                }

                $messages[] = $message;
            }
        }
        return implode(' ', $messages);
    }