check nullable fields and throw an exception when trying to set to null