# Validate a JSON body with an action

> Define an input schema on an action and let Total.js reject invalid requests before your code runs.

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

In Total.js 5 you declare the input of an action with `input`. A star in front of a field name (`*email`) marks it as required, and the type after the colon (`Email`) is validated by the framework. Your `action` function runs only when the data is valid.

Routes point to an action with the `-->` operator. The `*` prefix means "action" (as opposed to a controller function).

```js definitions/subscribe.js
NEWACTION('Subscribe/exec', {
	name: 'Subscribe to the newsletter',
	input: '*email:Email, name:String',
	action: function($, model) {
		$.success(model.email);
	}
});
```

```js controllers/subscribe.js
exports.install = function() {
	ROUTE('POST /subscribe/ --> *Subscribe/exec');
};
```

Send a valid body and the action is executed. Send an invalid e-mail address and the framework answers with a validation error without calling your function.
