diff --git a/audit/audit.go b/audit/audit.go index 2b466673a235669d3a5488cd004396484ca4f54e..e7c205580ab04c11192a4df70c925acffd9e95b2 100644 --- a/audit/audit.go +++ b/audit/audit.go @@ -2,6 +2,7 @@ package audit import ( "encoding/json" + "gitlab.com/uafrica/go-utils/errors" "reflect" "regexp" "strconv" @@ -17,6 +18,19 @@ type FieldChange struct { To interface{} `json:"change_to"` } +func VerifyAuditEvents(original interface{}, new interface{}) error { + structValue := reflect.ValueOf(original) + if structValue.Kind() != reflect.Struct { + return errors.New("original object is not of type struct") + } + + structValue = reflect.ValueOf(new) + if structValue.Kind() != reflect.Struct { + return errors.New("new object is not of type struct") + } + return nil +} + func GetChanges(original interface{}, new interface{}) (map[string]interface{}, error) { changes := map[string]interface{}{} changelog, err := diff.Diff(original, new)