code: func validateAffinity(affinity *core.Affinity, fldPath *field.Path) field.ErrorList {
  	allErrs := field.ErrorList{}
  
  	if affinity != nil {
  		if affinity.NodeAffinity != nil {
  			allErrs = append(allErrs, validateNodeAffinity(affinity.NodeAffinity, fldPath.Child("nodeAffinity"))...)
  		}
  		if affinity.PodAffinity != nil {
  			allErrs = append(allErrs, validatePodAffinity(affinity.PodAffinity, fldPath.Child("podAffinity"))...)
  		}
  		if affinity.PodAntiAffinity != nil {
  			allErrs = append(allErrs, validatePodAntiAffinity(affinity.PodAntiAffinity, fldPath.Child("podAntiAffinity"))...)
  		}
  	}
  
  	return allErrs
  }
docs: // validateAffinity checks if given affinities are valid