Skip to content

Commit

Permalink
FieldViolations
Browse files Browse the repository at this point in the history
  • Loading branch information
chyroc committed May 6, 2024
1 parent a73ce43 commit 19884bf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions type_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Error struct {
}

type ErrorDetail struct {
FieldViolations []*ErrorFieldViolation `json:"field_violations"`
PermissionViolations []*ErrorPermissionViolation `json:"permission_violations"`
Helps []*ErrorHelper `json:"helps"`
Message string `json:"message"`
Expand All @@ -49,6 +50,14 @@ func (r *ErrorDetail) String() string {
}
permissionSubjects[v.Type] = append(permissionSubjects[v.Type], v.Subject)
}
for i, v := range r.FieldViolations {
if i > 0 {
s.WriteString("\n")
}
s.WriteString(v.Field)
s.WriteString(": ")
s.WriteString(v.Description)
}

// action_scope_required: [docx:document, docx:document:readonly]
for i, action := range permissionActions {
Expand Down Expand Up @@ -83,6 +92,11 @@ func (r *ErrorDetail) String() string {
return s.String()
}

type ErrorFieldViolation struct {
Field string `json:"field"`
Description string `json:"description"`
}

type ErrorPermissionViolation struct {
Type string `json:"type"`
Subject string `json:"subject"`
Expand Down

0 comments on commit 19884bf

Please sign in to comment.