Query validation.