wix-incubator / accord

Accord: A sane validation library for Scala
http://wix.github.io/accord/
Other
530 stars 55 forks source link

Support monadic operations (map, flatMap) on collection contexts #52

Open holograph opened 8 years ago

holograph commented 8 years ago

Basically, CollectionDslContext needs to be extended with map, flatMap, filter etc. to support syntax such as:

case class Element(value: Int)
case class Container(elements: Seq[Element])

val containerValidator = Validator[Container] { c =>
  // First element's value must be 0
  c.elements.headOption.each map { _.value } should be == 0
}

For future consideration:

buildreactive commented 7 years ago

+1 would love to see this.