Rewrite of value validation with try/except to avoid python3 problem