Moving validity check out of parsing