Reduce duplication between QueryUtil and Validator