I'm running into validation issues after upgrading the Scalaz version to 7.2. The following code was working in prior Scalaz version.
def registerOrUpdate(enc: EncAdt, dx: List[DiagnosisAdt], provs: List[Provider], plans: List[InsurancePlan]): ValidationNel[AdtError, String \/ Int] = {
// First check that admit date is after contract start
enc.admitDT.fold[ValidationNel[AdtError, String \/ Int]](
MissingAdmitDate(enc).failureNel
) { admitTstamp =>
val beforeContractDate = fac.dosStart.exists(_ isAfter new DateTime(admitTstamp.getTime))
if (enc.accountNumber.trim == "") {
MissingFin(enc).failureNel
} else {
...
After upgrading Scalaz version following issue is being generated.
fold does not take type parameters
Any solution is appreciable.
Since you again didn't provide a Minimal, Complete, and Verifiable example in your question, it is hard to help you properly. Still if I copy the first AdtValidation
from my previous answer:
object AdtValidation {
type AdtValidation[A] = ValidationNel[AdtError, A]
implicit class AdtValidationSuccess[A](val value: A) extends AnyVal {
def successAdt: AdtValidation[A] = Validation.success[NonEmptyList[AdtError], A](value)
}
implicit class AdtValidationFailure(val value: AdtError) extends AnyVal {
def failureAdt[A]: AdtValidation[A] = Validation.failureNel[AdtError, A](value)
}
}
then the following simplification of your code compiles for me (provided you define other classes such as EncAdt
or MissingAdmitDate
)
import AdtValidation._
// the original works as well but this seems better to me
def registerOrUpdate(enc: EncAdt): AdtValidation[String \/ Int] = {
//def registerOrUpdate(enc: EncAdt): ValidationNel[AdtError, String \/ Int] = {
// First check that admit date is after contract start
enc.admitDT.fold[ValidationNel[AdtError, String \/ Int]](
// MissingAdmitDate(enc).failureNel
MissingAdmitDate(enc).failureAdt
) { admitTstamp =>
// val beforeContractDate = fac.dosStart.exists(_ isAfter new DateTime(admitTstamp.getTime))
if (enc.accountNumber.trim == "") {
// MissingFin(enc).failureNel
MissingFin(enc).failureAdt
} else {
//...
-\/(enc.transactionID.toString).successNel // this works
-\/(enc.transactionID.toString).successAdt // this also works
}
}
}
Hope this helps.