# Validate the query string in an action

> Declare query in NEWACTION to validate and convert the URL parameters, and read the clean values from $.query.

Framework: total5
Product: Total.js 5 (total5@0.0.19)
Language: en
Content-SHA256: 77ad7257e53db2b3d6562b8361c9bd5d8bae8913edd81e2448d322a1898445d9
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: total5-installed@total5@0.0.19
Review: not-recorded

Like `input` for the body and `params` for the path, `query` describes the query string. The framework validates it and converts the values (the page number below arrives as a real number); an invalid query answers with a validation error before your code runs.

```js definitions/search.js
NEWACTION('Search/exec', {
	name: 'Search',
	query: 'q:String, page:Number, *sort:Lowercase',
	action: function($) {
		$.callback({ q: $.query.q || '', page: $.query.page || 1, sort: $.query.sort });
	}
});
```

```js controllers/search.js
exports.install = function() {
	ROUTE('GET /search/ --> *Search/exec');
};
```
