code: func (enc *EncodingDefinition) Validate() *dslengine.ValidationErrors {
  	verr := new(dslengine.ValidationErrors)
  	if len(enc.MIMETypes) == 0 {
  		verr.Add(enc, "missing MIME type")
  		return verr
  	}
  	for _, m := range enc.MIMETypes {
  		_, _, err := mime.ParseMediaType(m)
  		if err != nil {
  			verr.Add(enc, "invalid MIME type %#v: %s", m, err)
  		}
  	}
  	if len(enc.PackagePath) > 0 {
  		rel := filepath.FromSlash(enc.PackagePath)
  		dir, err := os.Getwd()
  		if err != nil {
  			verr.Add(enc, "couldn't retrieve working directory %s", err)
  			return verr
  		}
  		_, err = build.Default.Import(rel, dir, build.FindOnly)
  		if err != nil {
  			verr.Add(enc, "invalid Go package path %#v: %s", enc.PackagePath, err)
  			return verr
  		}
  	} else {
  		for _, m := range enc.MIMETypes {
  			if _, ok := KnownEncoders[m]; !ok {
  				knownMIMETypes := make([]string, len(KnownEncoders))
  				i := 0
  				for k := range KnownEncoders {
  					knownMIMETypes[i] = k
  					i++
  				}
  				sort.Strings(knownMIMETypes)
  				verr.Add(enc, "Encoders not known for all MIME types, use Package to specify encoder Go package. MIME types with known encoders are %s",
  					strings.Join(knownMIMETypes, ", "))
  			}
  		}
  	}
  	if enc.Function != "" && enc.PackagePath == "" {
  		verr.Add(enc, "Must specify encoder package page with PackagePath")
  	}
  	return verr
  }
docs: // Validate validates the encoding MIME type and Go package path if set.