BZ-1171853 - Validate variable type when set

(cherry picked from commit 2b9617bc0b8754b3479dd051815e673605658ff3)