-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfile.go
49 lines (43 loc) · 2.5 KB
/
file.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// https://schema.ocsf.io/objects/file
package gcs
import (
"time"
"github.com/go-playground/validator/v10"
)
// WARN: ParentFolder and Path should be of type "Path Name" according to spec, does not exist rn
type File struct {
AccessedTime *time.Time `json:"accessed_time" validate:"omitempty"`
Accessor *User `json:"accessor" validate:"omitempty"`
Attributes uint `json:"attributes" validate:"omitempty"`
CompanyName string `json:"company_name" validate:"omitempty"`
Confidentiality string `json:"confidentiality" validate:"omitempty"`
ConfidentialityID uint8 `json:"confidentiality_id" validate:"omitempty"`
CreatedTime *time.Time `json:"created_time" validate:"omitempty"`
Creator *User `json:"creator" validate:"omitempty"`
Description string `json:"desc" validate:"omitempty"`
DigitalSignature *DigitalSignature `json:"signature" validate:"omitempty"`
ExtendedAttributes map[string]interface{} `json:"xattributes" validate:"omitempty"`
Fingerprints *[]Fingerprint `json:"fingerprints" validate:"omitempty"`
MIMEType string `json:"mime_type" validate:"omitempty"`
Modifier *User `json:"modifier" validate:"omitempty"`
Name string `json:"name" validate:"required"`
Owner *User `json:"owner" validate:"omitempty"`
ParentFolder string `json:"parent_folder" validate:"omitempty"`
Path string `json:"path" validate:"omitempty"`
Product *Product `json:"product" validate:"omitempty"`
SecurityDescriptor string `json:"security_descriptor" validate:"omitempty"`
Size int64 `json:"size" validate:"omitempty"`
System bool `json:"is_system" validate:"omitempty"`
Type string `json:"type" validate:"omitempty"`
TypeID *uint8 `json:"type_id" validate:"required"`
UniqueID string `json:"uid" validate:"omitempty"`
Version string `json:"version" validate:"omitempty"`
}
func ValidateFile(file *File) (*File, error) {
err := validator.New().Struct(file)
if err != nil {
ValidatorErrLog(err)
return nil, err
}
return file, nil
}