feat: added validation before persisting the query