Input types of NEWACTION
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 |
Base64 | SGVsbG8= | SGVsbG8= | schema-enums-and-formats |
Zip | 81101 | 81101 | schema-enums-and-formats |
Icon | ti ti-home | ti ti-home | 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. In this version Int does not truncate: 7.9 stays 7.9.
UID and GUID accept the values that UID() and GUID() create.
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);
}
});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() });
}