# Require selected variables to appear in the restriction part of search queries. (no-undeclared-var)

A RQL search query selecting a variable which is not declared in its restriction part is not valid. This ensure that all selected variables appear in restrictions.


## Rule Details

This rule aims to ensure that variables appearing in selection also appear in restrictions.

Examples of **incorrect** code for this rule:

```js
const query = rql`Any X WHERE Y is Person`
```

```js
const a = rql`Any X, Y, Z WHERE X is Person, X knows Y`
```

Examples of **correct** code for this rule:

```js
const query = rql`Any X WHERE X is Person`;
```

```js
const query = rql`Any X, N WHERE X is Person, X name N`;
```
