Official Document :
" Accord supports several native Scala control structures, notably ifs and pattern matching "
in http://wix.github.io/accord/dsl.html
case class InputData(
id: String,
name: Option[String] = None,
description: Option[String] = None,
items: Seq[String] = Seq.empty
)
Test Compilation OK :
implicit val inputDataValidator: Validator[InputData] = validator[InputData] { request =>
if (request.name.isDefined) {
} else {
request.name.mkString is notBlank
request.id is notBlank
request.description.mkString is notBlank
request.items is notEmpty
}
()
}
Test Compilation OK :
implicit val inputDataValidator: Validator[InputData] = validator[InputData] { request =>
request.name.mkString is notBlank
if (request.name.isDefined) {
} else {
request.id is notBlank
request.description.mkString is notBlank
request.items is notEmpty
}
()
}
Test Compilation Failed :
implicit val inputDataValidator: Validator[InputData] = validator[InputData] { request =>
if (request.name.isDefined) {
request.name.mkString is notBlank
} else {
request.id is notBlank
request.description.mkString is notBlank
request.items is notEmpty
}
()
}
Test Compilation Error :
[error] not found: value request
[error] if (request.name.isDefined) {
[error] ^
[error] one error found
Official Document : " Accord supports several native Scala control structures, notably ifs and pattern matching " in http://wix.github.io/accord/dsl.html
Library Dependencies :
Input Data :
Test Compilation OK :
Test Compilation OK :
Test Compilation Failed :
Test Compilation Error :