Add EINVALID code

Adds error code to distinguish validity check errors from other unexpected/operational errors.