build: add support for libvala-0.22

To make maintenance a little bit easier in the future, rewrite the
detection to use foreach instead of nesting the checks.