IsSubjectValid checks if a subject is valid or not
(subject *base.Subject)
| 142 | |
| 143 | // IsSubjectValid checks if a subject is valid or not |
| 144 | func 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 |
| 160 | func Tuple(tuple string) (*base.Tuple, error) { |
no test coverage detected