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

Function validateExpression

internal/filter/filter.go:33–71  ·  view source on GitHub ↗

validateExpression checks whether the given expression is a valid expression within the given reference schema.

(ref schema.Schema, e filter.Expression)

Source from the content-addressed store, hash-verified

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 {
34 switch e := e.(type) {
35 case *filter.ValuePath:
36 attr, err := validateAttributePath(ref, e.AttributePath)
37 if err != nil {
38 return nil
39 }
40 if err := validateExpression(
41 schema.Schema{
42 ID: ref.ID,
43 Attributes: attr.SubAttributes(),
44 },
45 e.ValueFilter,
46 ); err != nil {
47 return err
48 }
49 return nil
50 case *filter.AttributeExpression:
51 if _, err := validateAttributePath(ref, e.AttributePath); err != nil {
52 return err
53 }
54 return nil
55 case *filter.LogicalExpression:
56 if err := validateExpression(ref, e.Left); err != nil {
57 return err
58 }
59 if err := validateExpression(ref, e.Right); err != nil {
60 return err
61 }
62 return nil
63 case *filter.NotExpression:
64 if err := validateExpression(ref, e.Expression); err != nil {
65 return err
66 }
67 return nil
68 default:
69 panic(fmt.Sprintf("unknown expression type: %s", e))
70 }
71}
72
73// validateSubAttribute checks whether the given attribute name is a attribute within the given reference attribute.
74func validateSubAttribute(attr schema.CoreAttribute, subAttrName string) error {

Callers 2

ValidateMethod · 0.85
validatePathMethod · 0.85

Calls 2

validateAttributePathFunction · 0.85
SubAttributesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…