Pick the right input type for an action
The input of an action is a list of name:Type fields separated by commas. A * before the name makes the field required. Besides validating, many types convert the value, so the action receives clean data:
| Type | Result |
|---|---|
String, Number, Boolean, Date, Object, Array | the basic types (strings are trimmed, numbers and dates are parsed) |
Email, Phone, URL, UID, GUID, Base64, Color, Zip | validated formats |
Lowercase, Uppercase, Capitalize, Capitalize2, Name | text converted to that style: Capitalize capitalizes every word, Capitalize2 only the first letter of the text and lowercases the rest |
NEWACTION('Types/exec', {
name: 'Typed input',
input: '*email:Email, age:Number, active:Boolean, nick:Lowercase, code:Uppercase, title:Capitalize, sentence:Capitalize2, site:URL',
action: function($, model) {
$.callback(model);
}
});exports.install = function() {
ROUTE('POST /types/ --> *Types/exec');
};