validateAttributePath checks whether the given attribute path is a valid path within the given reference schema.
(ref schema.Schema, attrPath filter.AttributePath)
| 8 | |
| 9 | // validateAttributePath checks whether the given attribute path is a valid path within the given reference schema. |
| 10 | func 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. |
| 33 | func validateExpression(ref schema.Schema, e filter.Expression) error { |
no test coverage detected
searching dependent graphs…