def many[P <: CatalogPlan[Product, ChargeList, Status]]()

in app/com/gu/memsub/subsv2/services/CatalogService.scala [51:64]


  def many[P <: CatalogPlan[Product, ChargeList, Status]](plans: List[CatalogZuoraPlan], name: String)(implicit p: CatPlanReads[P]): ValidationNel[String, NonEmptyList[P]] = {
    val parsed: List[(ProductRatePlanId, ValidationNel[String, P])] =
      plans.map(plan => (plan.id, p.read(productIds, plan)))

    val failures = parsed.filter { case (_, validation) => validation.isFailure }
      .map { case (id, err) => (id, err.swap.map(_.list.toList).getOrElse(List.empty).mkString(", ")) }
      .toMap

    parsed.map { case (_, validation) => validation }
      .flatMap(_.toList) match {
      case n :: ns => Validation.success[NonEmptyList[String], NonEmptyList[P]](NonEmptyList.fromSeq(n, ns))
      case Nil => Validation.failureNel(ErrorReport(s"Failed to find $name in $stage", failures).toString)
    }
  }