O'Reilly logo

RESTful Web Services with Scala by Jos Dirksen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding validation to parameter processing

So far, we haven't really validated the incoming request. We just checked whether a parameter was provided, and if not, completely failed the request. This works, but is a rather cumbersome way of validating input parameters. Luckily, Unfiltered provides an alternative way of validation by using something called directives. With a directive, you tell Unfiltered what you expect, for example, a parameter that can be converted to an int, and Unfiltered will either get the value or respond with an appropriate response message. In other words, with a directive, you define a set of criteria the request must fulfill.

Introducing directives

Before we look at how we can use a directive in our scenario, let's look ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required