make sure value is valid