Instead of validating the input via `assert`s in user-accessible functions, raise appropriate errors.