code: func ValidateReplicaSetSpec(spec *apps.ReplicaSetSpec, fldPath *field.Path) field.ErrorList {
  	allErrs := field.ErrorList{}
  
  	allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(spec.Replicas), fldPath.Child("replicas"))...)
  	allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(spec.MinReadySeconds), fldPath.Child("minReadySeconds"))...)
  
  	if spec.Selector == nil {
  		allErrs = append(allErrs, field.Required(fldPath.Child("selector"), ""))
  	} else {
  		allErrs = append(allErrs, unversionedvalidation.ValidateLabelSelector(spec.Selector, fldPath.Child("selector"))...)
  		if len(spec.Selector.MatchLabels)+len(spec.Selector.MatchExpressions) == 0 {
  			allErrs = append(allErrs, field.Invalid(fldPath.Child("selector"), spec.Selector, "empty selector is invalid for deployment"))
  		}
  	}
  
  	selector, err := metav1.LabelSelectorAsSelector(spec.Selector)
  	if err != nil {
  		allErrs = append(allErrs, field.Invalid(fldPath.Child("selector"), spec.Selector, "invalid label selector"))
  	} else {
  		allErrs = append(allErrs, ValidatePodTemplateSpecForReplicaSet(&spec.Template, selector, spec.Replicas, fldPath.Child("template"))...)
  	}
  	return allErrs
  }
docs: // ValidateReplicaSetSpec tests if required fields in the ReplicaSet spec are set.