dropwizard/dropwizard — pull request #594 by nicktelford (2014-05-23 10:27:12+00:00)
Title: Enable validation of Optional values

To validate values contained in an `Optional` type, we need to use a new feature in Hibernate Validator 5.1, so this introduces a dependency version bump to 5.1.1.

This makes use of an *experimental* feature in Hibernate Validator, so I'm not 100% sure we'll want to make use of it yet.

To validate the contents of an `Optional`, you need to include an `@UnwrapValidatedValue` annotation on the property being validated:

```java
@Length(min = 32, max = 32)
@UnwrapValidatedValue
private Optional md5 = Optional.absent();
```

Absent values are considered `null` when validated, so their behaviour depends on your chosen constraints' handling of `null` values.

We have to register this inside `Bootstrap`, and I noticed that we don't (currently) expose a way for users to register more validation behaviour through `Bootstrap`, so we should probably look in to that.