refactor: Decompose validity checks and add support for calc()

Closes #7