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

Method validateExamples

expr/attribute.go:774–782  ·  view source on GitHub ↗

validateExamples makes sure that the attribute example values are compatible with the attribute type.

(ctx string, parent eval.Expression)

Source from the content-addressed store, hash-verified

772// validateExamples makes sure that the attribute example values are compatible
773// with the attribute type.
774func (a *AttributeExpr) validateExamples(ctx string, parent eval.Expression) *eval.ValidationErrors {
775 verr := new(eval.ValidationErrors)
776 for _, ex := range a.UserExamples {
777 if !a.Type.IsCompatible(ex.Value) { // DSL ensures ex.Value is not nil
778 verr.Add(parent, "%sexample value %#v is incompatible with type %s", ctx, ex.Value, a.Type.Name())
779 }
780 }
781 return verr
782}
783
784func (a *AttributeExpr) inheritRecursive(parent *AttributeExpr, seen map[*AttributeExpr]struct{}) {
785 if !a.shouldInherit(parent) {

Callers 1

ValidateMethod · 0.95

Calls 3

AddMethod · 0.80
IsCompatibleMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected