kevin
12/02/2024, 4:33 PMRight
. What’s the most elegant way to do this, I think I know how to short circuit the computation but in this case I have to be able to gather all the errorsdave08
12/02/2024, 5:02 PMdave08
12/02/2024, 5:04 PMkevin
12/02/2024, 5:05 PMAlejandro Serrano.Mena
12/02/2024, 6:38 PMkevin
12/02/2024, 9:55 PMStylianos Gakis
12/02/2024, 11:14 PMkevin
12/03/2024, 11:56 AMPair
(there are times I’ll want to validate more than two objects) so, is this going in the right direction and if so how do I improve the code?
// matchType is Either<MatchTypeError, MatchType>
// countryId is Either<CountryIdError, CountryId>
either {
zipOrAccumulate(
{
ensure(matchType.isRight()) { matchType.leftOrNull()!! }
matchType.bind()
}, {
val a: Int = 0
ensure(countryId.isRight()) { countryId.leftOrNull()!! }
countryId.bind()
}
) { matchType, countryId ->
Pair(matchType, countryId)
}
}
dave08
12/03/2024, 11:57 AMdave08
12/03/2024, 11:58 AMdave08
12/03/2024, 11:58 AMkevin
12/03/2024, 11:59 AM