abstract query validation