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:
c.elements.headOption.each is validWith { _.value should be == 0 }
c.elements startsWith { _.value should be == 0 }
c.elements.head is validWith { ... } -- unlikely as would require heuristic wrapping of collection access
Basically,
CollectionDslContext
needs to be extended withmap
,flatMap
,filter
etc. to support syntax such as:For future consideration:
c.elements.headOption.each is validWith { _.value should be == 0 }
c.elements startsWith { _.value should be == 0 }
c.elements.head is validWith { ... }
-- unlikely as would require heuristic wrapping of collection access