2017-07-26 73 views
2

升级后的播放框架从2.5升级到2.6后,出现以下错误。 (这是能与2.5编译) 斯卡拉版本:2.11.8不带Form的约束验证与Play2.6

ambiguous reference to overloaded definition, 
[error] both method emailAddress in trait Constraints of type => play.api.data.validation.Constraint[String] 
[error] and method emailAddress in trait Constraints of type (errorMessage: String)play.api.data.validation.Constraint[String] 
[error] match argument types (String) 
[error] Constraints.emailAddress("[email protected]") 
        ^

有没有办法使用的约束下与方法2.6播放?

import play.api.data.validation._ 

val result = Constraints.emailAddress("[email protected]") 

回答

0

EMAILADDRESS是在内部调用另一重载方法EMAILADDRESS的方法:因此,如果调用EMAILADDRESS与参数,这将使编译错误(字符串的errorMessage =“error.email”)的方法,这样你就可以像测试这

val result = Constraints.emailAddress 

    result("[email protected]")