MCPcopy Create free account
hub / github.com/apache/casbin / GetValuesForFieldInPolicyAllTypes

Method GetValuesForFieldInPolicyAllTypes

model/policy.go:423–437  ·  view source on GitHub ↗

GetValuesForFieldInPolicyAllTypes gets all values for a field for all rules in a policy of all ptypes, duplicated values are removed.

(sec string, fieldIndex int)

Source from the content-addressed store, hash-verified

421
422// GetValuesForFieldInPolicyAllTypes gets all values for a field for all rules in a policy of all ptypes, duplicated values are removed.
423func (model Model) GetValuesForFieldInPolicyAllTypes(sec string, fieldIndex int) ([]string, error) {
424 values := []string{}
425
426 for ptype := range model[sec] {
427 v, err := model.GetValuesForFieldInPolicy(sec, ptype, fieldIndex)
428 if err != nil {
429 return nil, err
430 }
431 values = append(values, v...)
432 }
433
434 util.ArrayRemoveDuplicates(&values)
435
436 return values, nil
437}
438
439// GetValuesForFieldInPolicyAllTypesByName gets all values for a field for all rules in a policy of all ptypes, duplicated values are removed.
440func (model Model) GetValuesForFieldInPolicyAllTypesByName(sec string, field string) ([]string, error) {

Callers 2

GetAllRolesMethod · 0.80

Calls 2

ArrayRemoveDuplicatesFunction · 0.92

Tested by

no test coverage detected