【发布时间】:2014-06-05 18:28:24
【问题描述】:
我遇到了以下方法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
}
}
}
我定义了toLazyOr 方法,然后我尝试在我的代码中使用它。但是,我不确定如何使用它。
我试过了:
val adminForm = Form(
mapping(
"email" -> (email verifying toLazyOr(nonEmpty, minLength(4)) )
)
还有:
val adminForm = Form(
mapping(
"email" -> (email verifying toLazyOr(nonEmpty or minLength(4)) )
)
两者都不起作用,我目前的 scala 知识非常基础。 请帮忙。
【问题讨论】: