Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
holograph opened this issue Oct 13, 2015 · 1 comment
Open
Assignees
Milestone

Comments

@holograph
Copy link
Contributor

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
@holograph holograph added this to the 0.7 milestone Oct 13, 2015
@holograph holograph self-assigned this Oct 13, 2015
@buildreactive
Copy link

+1 would love to see this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants