add optional attribute. Only call validation if input is not empty.