Reputation: 215
I came across the below method here
implicit def toLazyOr[T](cons: Constraint[T]) = new {
def or(other: Constraint[T]) = Constraint { field: T =>
cons(field) match {
case Valid => other(field)
case Invalid => Invalid
}
}
}
I defined toLazyOr
method and then I am trying to use it in my code. But, I am not sure how do I use this.
I tried:
val adminForm = Form(
mapping(
"email" -> (email verifying toLazyOr(nonEmpty, minLength(4)) )
)
And:
val adminForm = Form(
mapping(
"email" -> (email verifying toLazyOr(nonEmpty or minLength(4)) )
)
Both are not working and my scala knowledge for the moment is very basic. Please help.
Upvotes: 0
Views: 44
Reputation: 4593
Without knowing very much about play:
If the implicit conversion is in scope, the following should work:
val adminForm = Form(
mapping(
"email" -> (email verifying (nonEmpty or minLength(4)))
))
That's the thing about implicit conversions: You don't have to call them explicitly. See this answer for more information about where the compiler is looking for implicits.
Upvotes: 3