2017-07-26 72 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]")