Guys I'm trying to use arrow to do validations. I ...
# arrow
v
Guys I'm trying to use arrow to do validations. I have 14 parameters that i need to validate in order to create an instance of a data class, but zipOrAccumulate only takes up to 9. The requirement is that it validates them all and lists all the errors. What's the correct approach?
j
I know you might want to stick to Arrow. But if you have a complex use case, you might consider Akkurate, a validation library I'm maintaining. 🙂 With it, you can easily accumulate the errors, and it has an integration with Arrow's typed errors. Feel free to have a look!
akkurate 4
👀 1
g
There is also a PR for an “accumulate” dsl: https://github.com/arrow-kt/arrow/pull/3436
😮 1
👀 1
g
14 parameters? Maybe split these validation across your layers and/or services?
👍 1
v
14 parameters coz its just one domain object that i build from the excel workbook. Each sheet contains data for one object and from the domain perspective it's either all properly parsed and returns a list of objects or it's malformed and user needs to know which sheet contains what problems. Doesnt make sense to me to validate it multiple times 🙂
s
Any feedback on this PR would be awesome 🙏 https://github.com/arrow-kt/arrow/pull/3436 In the meanwhile you can work around it using
Tuple
as well.
Copy code
zipOrAccumulate(
  zipOrAccumulate(
    /* 9 lambdas */,
    ::Tuple9
  ),
  zipOrAccumulate(
    /* 5 lambdas */,
    ::Tuple5
  )
) { (a, b, c, d, ..), (a, b, ...) -> }
v
Thanks Simon! Appreciate your work!
thank you color 1
🙌 1
g
Simon is gold to humanity
❤️ 3