public function addError($messageCode, $field = '*', $options = []) {
        $error = [];
        if (substr($messageCode, 0, 1) === '@') {
            $error['message'] = substr($messageCode, 1);
        } else {
            $error['code'] = $messageCode;
        }
        if (is_array($field)) {
            $fieldname = array_select(['path', 'name'], $field);

            if ($fieldname) {
                // This is a full field object.
                $fieldKey = $fieldname;
                $error['field'] = $fieldKey;
            } else {
                $fieldKey = '*';
                $error['field'] = $field;
            }
        } else {
            $fieldKey = $field;
            if ($field !== '*') {
                $error['field'] = $field;
            }
        }

        if (is_array($options)) {
            $error += $options;
        } else if (is_int($options)) {
            $error['status'] = $options;
        }

        $this->errors[$fieldKey][] = $error;

        return $this;
    }