improve non-scalar key validation