ValidateWorkspaceID reports whether the workspace identity can safely occupy one NATS subject token and one protocol envelope field.
(workspaceID string)
| 117 | // ValidateWorkspaceID reports whether the workspace identity can safely occupy |
| 118 | // one NATS subject token and one protocol envelope field. |
| 119 | func ValidateWorkspaceID(workspaceID string) error { |
| 120 | trimmed := strings.TrimSpace(workspaceID) |
| 121 | if trimmed == "" { |
| 122 | return fmt.Errorf("%w: workspace_id is required", ErrMissingField) |
| 123 | } |
| 124 | if strings.ContainsAny(trimmed, ". *>") || containsControlCharacter(trimmed) { |
| 125 | return fmt.Errorf("%w: workspace_id=%q", ErrInvalidField, workspaceID) |
| 126 | } |
| 127 | return nil |
| 128 | } |
| 129 | |
| 130 | // ValidateSurface reports whether the surface matches the RFC conversation values. |
| 131 | func ValidateSurface(surface Surface) error { |
no test coverage detected