Early draft

I'm not suggesting that we merge any of this but a PR makes it easier to discuss.
This will only set one error message if there are several problems, since it will match the case on the first error. Wouldn't it be more useful to have a list of all the errors?