improve check validity of expected type, a check is done at the end of the setFromValue / setToValue