Refactor data type validation