Is there any possibility to combine different errors from multiple variables using NonEmptyList
type ValidationResult[A] = ValidatedNel[String, A]
def throwErrorsWhenNumberIsLessThan6(x:Int):ValidationResult[Int] = if(x<6) s"$x !> 6".invalidNel else (x+6).validNel
def throwErrorsWhenStringLengthIsLessThan6(x:String):ValidationResult[String] = if(x.length<6) s"$x length > 6".invalidNel else (x+" OK!!! ").validNel
val ints = Range.apply(1,10).map(throwErrorsWhenNumberIsLessThan6).toList
val strings = Range.apply(1,10).map(e => throwErrorsWhenStringLengthIsLessThan6(e.toString)).toList
Is there a way to combine all the errors available in ints
and strings
?
Assuming that ints
and strings
will hold same data type in NonEmptyList
.