Treat invalid uuid as nil

When an invalid value is set for an uuid field, Postgresql raise a casting error.
```
ActiveRecord::StatementInvalid: PG::InvalidTextRepresentation: ERROR:  invalid input syntax for uuid: "foobar"
```
Previously we had a to validate the format for every uuid manually. This PR converts all invalid uuid to nil.