Building a query for save should be done after calling validate

Fix regression #163.
Building a query with an invalid date can throw, so we should validate the
document, and only then build the query.