code: func (s ServiceCommonGeneratorV1) validate() error {
  	if len(s.Name) == 0 {
  		return fmt.Errorf("name must be specified")
  	}
  	if len(s.Type) == 0 {
  		return fmt.Errorf("type must be specified")
  	}
  	if s.ClusterIP == v1.ClusterIPNone && s.Type != v1.ServiceTypeClusterIP {
  		return fmt.Errorf("ClusterIP=None can only be used with ClusterIP service type")
  	}
  	if s.ClusterIP != v1.ClusterIPNone && len(s.TCP) == 0 && s.Type != v1.ServiceTypeExternalName {
  		return fmt.Errorf("at least one tcp port specifier must be provided")
  	}
  	if s.Type == v1.ServiceTypeExternalName {
  		if errs := validation.IsDNS1123Subdomain(s.ExternalName); len(errs) != 0 {
  			return fmt.Errorf("invalid service external name %s", s.ExternalName)
  		}
  	}
  	return nil
  }
docs: // validate validates required fields are set to support structured generation
  // TODO(xiangpengzhao): validate ports are identity mapped for headless service when we enforce that in validation.validateServicePort.