Check that values are valid before setting them