MCPcopy Create free account
hub / github.com/goadesign/goa / validateAttributeAccess

Method validateAttributeAccess

expr/interceptor.go:147–158  ·  view source on GitHub ↗

validateAttributeAccess validates that all attributes in attr exist in obj

(m *MethodExpr, source string, verr *eval.ValidationErrors, target *AttributeExpr, attr *AttributeExpr)

Source from the content-addressed store, hash-verified

145
146// validateAttributeAccess validates that all attributes in attr exist in obj
147func (i *InterceptorExpr) validateAttributeAccess(m *MethodExpr, source string, verr *eval.ValidationErrors, target *AttributeExpr, attr *AttributeExpr) {
148 attrObj := AsObject(attr.Type)
149 if attrObj == nil {
150 verr.Add(m, "interceptor %q %s attribute is not an object", i.Name, source)
151 return
152 }
153 for _, att := range *attrObj {
154 if target.Find(att.Name) == nil {
155 verr.Add(m, "interceptor %q cannot %s attribute %q: attribute does not exist", i.Name, source, att.Name)
156 }
157 }
158}

Callers 1

validateMethod · 0.95

Calls 3

AsObjectFunction · 0.85
AddMethod · 0.80
FindMethod · 0.80

Tested by

no test coverage detected