# Input types of NEWACTION

> Choose types for input, params, query and output definitions, including conversions and rejected values.

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

A definition is a list of `name:Type` separated by commas, for example `*email:Email, age:Number`. A `*` before the name makes the field required. The same format is used by `input` (the body), `params`, `query` and `output`. **The type converts the value**: the action receives the converted value, not the text that was sent.

The names of the types are not case sensitive. Every type below was checked by sending the value in the second column.

| Type | Value sent | Value received | Notes |
|---|---|---|---|
| `String` | `  hello  ` | `hello` | Text; leading and trailing spaces are removed. |
| `Text` | `  text  ` | `  text  ` | Text kept exactly as it was sent. |
| `Email` | ` A@B.CZ ` | `a@b.cz` | A valid email address, in lowercase; anything else is rejected. |
| `Phone` | `+421 900 123 456` | `+421900123456` | A phone number; spaces are removed. |
| `URL` | `https://totaljs.com/x` | `https://totaljs.com/x` | A valid URL; anything else is rejected. |
| `Name` | `john smith` | `John Smith` | Capitalizes every word. |
| `Capitalize` | `hello big world` | `Hello Big World` | Capitalizes every word. |
| `Capitalize2` | `HELLO big WORLD` | `Hello big world` | Capitalizes the first letter only and lowercases the rest. |
| `Lowercase` | `ABC` | `abc` | Lowercase. |
| `Uppercase` | `abc` | `ABC` | Uppercase. |
| `Search` | `Žluťoučký Kůň` | `zlutoucki kun` | Lowercase without accents, for searching. |
| `SafeString` | `plain text` | `plain text` | Text; a value with HTML tags such as `<b>` is rejected. |
| `Color` | `#FF0000` | `#FF0000` | [schema-enums-and-formats](/en/total5/schema-enums-and-formats/) |
| `Base64` | `SGVsbG8=` | `SGVsbG8=` | [schema-enums-and-formats](/en/total5/schema-enums-and-formats/) |
| `Zip` | `81101` | `81101` | [schema-enums-and-formats](/en/total5/schema-enums-and-formats/) |
| `Icon` | `ti ti-home` | `ti ti-home` | [schema-enums-and-formats](/en/total5/schema-enums-and-formats/) |
| `Number` | `12.5` | `12.5` | A number; the text is converted. |
| `Float` | `3.14` | `3.14` | A number; the text is converted. |
| `Decimal` | `2.5` | `2.5` | A number; the text is converted. |
| `Boolean` | `true` | `true` | `true` or `false`; the text `true` is converted. |
| `Date` | `2026-01-05` | `2026-01-05T00:00:00.000Z` | A date. In JSON it is sent as an ISO text. |

Other forms:

| Form | Example | Notes |
|---|---|---|
| `[String]`, `[Number]` | `ze_arr:[String]` | An array of that type: every item is converted. |
| `{ x:Number, y:String }` | `zg_obj:{ x:Number, y:String }` | A nested object, validated with its own fields. |
| `String(5)` | `zd_max:String(5)` | A text of at most 5 characters; a longer text is rejected. |

A value that does not fit the type is rejected with status 400 and the name of the field in the error. These values were rejected in the checks: `SafeString` with `<b>x</b>`, `String(5)` with ten characters, a `UID` with `abc`, and a `GUID` with `not-guid`. The boundary recipe verifies `Int`, `SmallInt`, `TinyInt`, `Number2`: [numeric-schema-boundaries](/en/total5/numeric-schema-boundaries/). In this version `Int` does not truncate: `7.9` stays `7.9`.

`UID` and `GUID` accept the values that `UID()` and `GUID()` create.

```js definitions/types.js
NEWACTION('Types/all', {
	name: 'Every type',
	input: 'a_string:String, b_text:Text, c_email:Email, d_phone:Phone, e_url:URL, f_name:Name, g_capitalize:Capitalize, h_capitalize2:Capitalize2, i_lowercase:Lowercase, j_uppercase:Uppercase, k_search:Search, l_safestring:SafeString, m_color:Color, n_base64:Base64, o_zip:Zip, p_icon:Icon, q_number:Number, r_float:Float, s_decimal:Decimal, t_boolean:Boolean, u_date:Date, ze_arr:[String], zf_nums:[Number], zg_obj:{ x:Number, y:String }, zd_max:String(5)',
	action: function($, model) {
		$.callback(model);
	}
});

NEWACTION('Types/ids', {
	name: 'UID and GUID',
	input: '*id:UID, *key:GUID',
	action: function($, model) {
		$.callback(model);
	}
});
```

```js controllers/types.js
exports.install = function() {
	ROUTE('POST /types/ @json --> *Types/all');
	ROUTE('POST /ids/ @json --> *Types/ids');
	ROUTE('GET /newids/', ids);
};

function ids($) {
	$.json({ id: UID(), key: GUID() });
}
```
