Added an exception in case isValid is called before setPayload().