Use this:

${THEVAR:+x}

Which will expand to “x” if THEVAR is set and not empty.

Alternatively, this test can be used:

if [[ ! -v THEVAR ]]; then
    echo "THEVAR is not set"
fi

But that will work even if THEVAR is set but empty.

I work as a freelancer, so if you don’t want to do that kind of things yourself or don’t have the time, just drop me a line to hire me.