-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate.go
More file actions
46 lines (42 loc) · 1.56 KB
/
Copy pathvalidate.go
File metadata and controls
46 lines (42 loc) · 1.56 KB
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
package main
import "fmt"
var (
validSensitivities = map[string]bool{
"public": true, "internal": true, "confidential": true, "restricted": true,
}
validTrustLevels = map[string]bool{
"verified": true, "unverified": true, "untrusted": true,
}
validRequesterTypes = map[string]bool{
"user": true, "tool": true, "system": true,
}
validSessionTrusts = map[string]bool{
"high": true, "medium": true, "low": true,
}
)
// validateIngestRequest checks structural validity before document ingestion.
func validateIngestRequest(req IngestRequest) error {
if req.Name == "" {
return fmt.Errorf("name is required")
}
if req.Content == "" {
return fmt.Errorf("content is required")
}
if req.SensitivityLabel != "" && !validSensitivities[req.SensitivityLabel] {
return fmt.Errorf("invalid sensitivity_label: %s (must be public, internal, confidential, or restricted)", req.SensitivityLabel)
}
if req.TrustLevel != "" && !validTrustLevels[req.TrustLevel] {
return fmt.Errorf("invalid trust_level: %s (must be verified, unverified, or untrusted)", req.TrustLevel)
}
return nil
}
// validateRetrievalRequest checks structural validity of a retrieval request.
func validateRetrievalRequest(req RetrievalRequest) error {
if req.RequesterType != "" && !validRequesterTypes[req.RequesterType] {
return fmt.Errorf("invalid requester_type: %s (must be user, tool, or system)", req.RequesterType)
}
if req.SessionTrust != "" && !validSessionTrusts[req.SessionTrust] {
return fmt.Errorf("invalid session_trust: %s (must be high, medium, or low)", req.SessionTrust)
}
return nil
}