Jak zakodować tę logikę walidacji w Scali?

Przypuśćmy, że chciałbym zakodować następującą logikę w Scali

val xdir = System.getProperty("XDir")
if (xdir == null)
   error("No XDir") // log the error and exit

val ydir = System.getProperty("YDir") 
if (ydir == null)
   error("No YDir")

if (!new File(xdir).isDirectory)
   error("XDir is not a directory")

if (!new File(ydir).isDirectory)
   error("YDir is not a directory")

if (!new File(xdir).exists)
   error("XDir does not exis")

if (!new File(ydir).exists)
   error("YDir does not exist")
...
(and so on)

Jak najlepiej kodować ten łańcuch walidacji w Scali?

questionAnswers(3)

yourAnswerToTheQuestion