MCPcopy Create free account
hub / github.com/elimity-com/scim / validateAttributePath

Function validateAttributePath

internal/filter/filter.go:10–30  ·  view source on GitHub ↗

validateAttributePath checks whether the given attribute path is a valid path within the given reference schema.

(ref schema.Schema, attrPath filter.AttributePath)

Source from the content-addressed store, hash-verified

8
9// validateAttributePath checks whether the given attribute path is a valid path within the given reference schema.
10func validateAttributePath(ref schema.Schema, attrPath filter.AttributePath) (schema.CoreAttribute, error) {
11 if uri := attrPath.URI(); uri != "" && uri != ref.ID {
12 return schema.CoreAttribute{}, fmt.Errorf("the uri does not match the schema id: %s", uri)
13 }
14
15 attr, ok := ref.Attributes.ContainsAttribute(attrPath.AttributeName)
16 if !ok {
17 return schema.CoreAttribute{}, fmt.Errorf(
18 "the reference schema does not have an attribute with the name: %s",
19 attrPath.AttributeName,
20 )
21 }
22 // e.g. name.givenName
23 // ^________
24 if subAttrName := attrPath.SubAttributeName(); subAttrName != "" {
25 if err := validateSubAttribute(attr, subAttrName); err != nil {
26 return schema.CoreAttribute{}, err
27 }
28 }
29 return attr, nil
30}
31
32// validateExpression checks whether the given expression is a valid expression within the given reference schema.
33func validateExpression(ref schema.Schema, e filter.Expression) error {

Callers 2

validateExpressionFunction · 0.85
validatePathMethod · 0.85

Calls 2

validateSubAttributeFunction · 0.85
ContainsAttributeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…