code: func (l *LinkDefinition) Validate() *dslengine.ValidationErrors {
  	verr := new(dslengine.ValidationErrors)
  	if l.Name == "" {
  		verr.Add(l, "Links must have a name")
  	}
  	if l.Parent == nil {
  		verr.Add(l, "Link must have a parent media type")
  	}
  	if l.Parent.ToObject() == nil {
  		verr.Add(l, "Link parent media type must be an Object")
  	}
  	att, ok := l.Parent.ToObject()[l.Name]
  	if !ok {
  		verr.Add(l, "Link name must match one of the parent media type attribute names")
  	} else {
  		mediaType, ok := att.Type.(*MediaTypeDefinition)
  		if !ok {
  			verr.Add(l, "attribute type must be a media type")
  		} else {
  			viewFound := false
  			view := l.View
  			for v := range mediaType.Views {
  				if v == view {
  					viewFound = true
  					break
  				}
  			}
  			if !viewFound {
  				verr.Add(l, "view %#v does not exist on target media type %#v", view, mediaType.Identifier)
  			}
  		}
  	}
  	return verr.AsError()
  }
docs: // Validate checks that the link definition is consistent: it has a media type or the name of an
  // attribute part of the parent media type.