wix-incubator/accord

Multiple multiple validation rules in control structures is incorrect

CatTail opened this issue · 2 comments

When using multiple is false validation rules inside control structure, it seems only the last rule matters, below is an example to reproduce the issue.

object AccordConditionIssueApp extends App {

  case class Something(bool1: Boolean, bool2: Boolean, bool3: Boolean)

  val condition = true

  implicit val somethingValidator = validator[Something] { o =>
    if (condition) {
      o.bool1 is false
      o.bool2 is false
    }

    o.bool3 is false
  }

  // Following example expected to be invalid, but it turned out to be valid
  val invalidSomething = Something(bool1 = true, bool2 = false, bool3 = false)
  println(validate(invalidSomething)) // => Success
}

https://github.com/CatTail/scala-playground/blob/77b265529afab42e1cbd28beb296b3a67b3cf343/src/main/scala/com/example/playground/AccordApp.scala#L32-L50

Confirmed. Looking into it

PR issued. @noam-almog ball's in your court :-)