I'm trying to figure out the right pattern to appl...
# arrow
m
I'm trying to figure out the right pattern to apply multiple validations to a single object. After, I I thought I would structure this as something like *
fun validateCriteriaA(thing: Thing): Validated<ValidationError, Thing>
*
fun validateCriteriaB(thing: Thing, otherInput: Int): : Validated<ValidationError, Thing>
If this is the right approach, what is the right way to combine them and get all validation errors? So far, I had something like:
Copy code
Validated.applicative(NonEmptyList.semigroup<Thing>())
    .map(
        validateCriteriaA(thing).toValidatedNel(),
        validateCriteriaB(thing, someInput).toValidatedNel()
    ) { (thing1, thing2) ->
    // this doesn't feel right, since I'm only validating a single thing
}.fix()
Any suggestions?