Need to add "()" to imply discarded non-Unit value to suppress error when defining validator with DSL
webblin034 opened this issue · 1 comments
webblin034 commented
Library Dependencies :
libraryDependencies ++= Seq(
"com.wix" %% "accord-core" % "0.7.6" % Test,
"org.scalatest" %% "scalatest" % "3.2.2" % Test
)
Input Data :
case class InputData(
id: String,
name: Option[String] = None,
description: Option[String] = None,
items: Seq[String] = Seq.empty
)
Test Compilation Pass With () !
implicit val inputDataValidator: Validator[InputData] = validator[InputData] { request =>
request.id is notBlank
request.name.mkString is notBlank
request.description.mkString is notBlank
request.items is notEmpty
()
}
Test Compilation Failed Without () !
implicit val inputDataValidator: Validator[InputData] = validator[InputData] { request =>
request.id is notBlank
request.name.mkString is notBlank
request.description.mkString is notBlank
request.items is notEmpty
}
Test Compilation Error :
[error] discarded non-Unit value
[error] request.items is notEmpty
[error] ^
[error] one error found
noam-almog commented
i'm not sure what you are trying to achieve here