MCPcopy Create free account
hub / github.com/Permify/permify / IsSubjectValid

Function IsSubjectValid

pkg/tuple/tuple.go:144–157  ·  view source on GitHub ↗

IsSubjectValid checks if a subject is valid or not

(subject *base.Subject)

Source from the content-addressed store, hash-verified

142
143// IsSubjectValid checks if a subject is valid or not
144func IsSubjectValid(subject *base.Subject) bool {
145 if subject.GetType() == "" {
146 return false
147 }
148
149 if subject.GetId() == "" {
150 return false
151 }
152
153 if IsDirectSubject(subject) {
154 return subject.GetRelation() == "" // relation should be empty for user subjects
155 }
156 return subject.GetRelation() != "" // relation should not be empty for non-user subjects
157}
158
159// Tuple parses a tuple string and returns a Tuple object
160func Tuple(tuple string) (*base.Tuple, error) {

Callers 1

tuple_test.goFile · 0.85

Calls 4

IsDirectSubjectFunction · 0.85
GetTypeMethod · 0.65
GetIdMethod · 0.45
GetRelationMethod · 0.45

Tested by

no test coverage detected