title: In Scala Cats Validated, how can combine ordered validations
body: <p>In <a href="https://gist.github.com/satyagraha/897e427bfb5ed203e9d3054ac6705704" rel="nofollow noreferrer">https://gist.github.com/satyagraha/897e427bfb5ed203e9d3054ac6705704</a> I have posted a Scala Cats validation scenario which seems reasonable, but I haven't found a very neat solution.</p>
  
  <p>Essentially, there is a two-stage validation, where individual fields are validated, then a class constructor is called which may throw due to internal checks (in general this may not be under my control to change, hence the exception handling code). We wish to not to call the constructor if any field validation fails, but also combine any constructor failure into the final result. "Fail-fast" is definitely right here for the two-phase check.</p>
  
  <p>This is a kind of <code>flatMap</code> problem, which the <code>cats.data.Validated</code> framework appears to handle via the <code>cats.data.Validated#andThen</code>operation. However I couldn't find a particularly neat solution to the problem as you can see in the code. There are quite a limited number of operations available on a <code>cats.syntax.CartesianBuilder</code> and is wasn't clear to me how to link it with the <code>andThen</code> operation.</p>
  
  <p>Any ideas welcome! Note there is a Cats issue <a href="https://github.com/typelevel/cats/issues/1343" rel="nofollow noreferrer">https://github.com/typelevel/cats/issues/1343</a> which possibly is related, not sure.</p>