Here below is a case class that verifies the name parameter is neither null nor empty:
case class MyClass(name: String) {
require(Option(name).map(!_.isEmpty) == Option(true), "name is null or empty")
}
As expected, passing null or an empty string to name results in an IllegalArgumentException.
Is it possible to rewrite the validation to get either Success or Failure instead of throwing an IllegalArgumentException