This chunk of code is the same as in `validate()`--could be factored out.