We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 12d29e7 commit 0c4ee47Copy full SHA for 0c4ee47
pkg/models/idorkey.go
@@ -0,0 +1,27 @@
1
+package models
2
+
3
+import (
4
+ "errors"
5
+ "fmt"
6
+)
7
8
+// NamespacedIDOrKey represents a namespaced id or key (when we don't know if a specific entity is either a key or an id)
9
+// If the type of entity is known please use the ref package or the NamespacedID or the NamespacedKey types
10
+type NamespacedIDOrKey struct {
11
+ Namespace string `json:"namespace"`
12
+ IDOrKey string `json:"idOrKey"`
13
+}
14
15
+func (n NamespacedIDOrKey) Validate() error {
16
+ var errs []error
17
18
+ if n.Namespace == "" {
19
+ errs = append(errs, fmt.Errorf("namespace is required"))
20
+ }
21
22
+ if n.IDOrKey == "" {
23
+ errs = append(errs, fmt.Errorf("idOrKey is required"))
24
25
26
+ return errors.Join(errs...)
27
0 commit comments