Validate query input