Return an error object when validation fails