code: func ValidateAffinityInPodAnnotations(annotations map[string]string, fldPath *field.Path) field.ErrorList {
  	allErrs := field.ErrorList{}
  
  	affinity, err := api.GetAffinityFromPodAnnotations(annotations)
  	if err != nil {
  		allErrs = append(allErrs, field.Invalid(fldPath, api.AffinityAnnotationKey, err.Error()))
  		return allErrs
  	}
  
  	if affinity.NodeAffinity != nil {
  		na := affinity.NodeAffinity
  
  		// TODO: Uncomment the next three lines once RequiredDuringSchedulingRequiredDuringExecution is implemented.
  		// if na.RequiredDuringSchedulingRequiredDuringExecution != nil {
  		//	allErrs = append(allErrs, ValidateNodeSelector(na.RequiredDuringSchedulingRequiredDuringExecution, fldPath.Child("requiredDuringSchedulingRequiredDuringExecution"))...)
  		// }
  
  		if na.RequiredDuringSchedulingIgnoredDuringExecution != nil {
  			allErrs = append(allErrs, ValidateNodeSelector(na.RequiredDuringSchedulingIgnoredDuringExecution, fldPath.Child("requiredDuringSchedulingIgnoredDuringExecution"))...)
  		}
  
  		if len(na.PreferredDuringSchedulingIgnoredDuringExecution) > 0 {
  			allErrs = append(allErrs, ValidatePreferredSchedulingTerms(na.PreferredDuringSchedulingIgnoredDuringExecution, fldPath.Child("preferredDuringSchedulingIgnoredDuringExecution"))...)
  
  		}
  	}
  
  	return allErrs
  }
docs: // ValidateAffinityInPodAnnotations tests that the serialized Affinity in Pod.Annotations has valid data