ForgeTotal.js 5
en

Total.js 5

Declare typed route parameters in an action

Total.js 5 · total5@0.0.19 actionsroutingvalidation Executed against Total.js 5

An action can describe the parameters it expects with params, using the same type names as input. UIDs are generated with UID() and include a checksum, so an arbitrary string is not a valid UID. When a parameter does not match its type, the framework answers with a validation error and your action function is not called.

definitions/items.js
NEWACTION('Items/read', {
	name: 'Read an item',
	params: 'id:UID',
	action: function($) {
		$.success($.params.id);
	}
});
controllers/items.js
exports.install = function() {
	ROUTE('GET /items/{id}/ --> *Items/read');
};