Refactor model and search query validations