| Package: | CQ.Ext.form |
| Class: | VTypes |
| Extends: | Object |
| Clientlib: | cq.widgets |
This is a singleton object which contains a set of commonly used field validation functions. The validations provided are basic and intended to be easily customizable and extended.
To add custom VTypes specify the vtype validation
test function, and optionally specify any corresponding error text to display and any keystroke
filtering mask to apply. For example:
// custom Vtype for vtype:'time'
var timeTest = /^([1-9]|1[0-9]):([0-5][0-9])(\s[a|p]m)$/i;
CQ.Ext.apply(CQ.Ext.form.VTypes, {
// vtype validation function
time: function(val, field) {
return timeTest.test(val);
},
// vtype Text property: The error text to display when the validation function returns false
timeText: 'Not a valid time. Must be in the format "12:34 PM".',
// vtype Mask property: The keystroke filter mask
timeMask: /[\d\s:amp]/i
});
Another example:
// custom Vtype for vtype:'IPAddress'
CQ.Ext.apply(CQ.Ext.form.VTypes, {
IPAddress: function(v) {
return /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(v);
},
IPAddressText: 'Must be a numeric IP address',
IPAddressMask: /[\d\.]/i
});| Property | Defined By | |
|---|---|---|
|
alphaMask : RegExp
The keystroke filter mask to be applied on alpha input. Defaults to:
/[a-z_]/i
|
VTypes | |
|
alphaText : String The error text to display when the alpha validation function returns false. Defaults to:
'This field should only con...
The error text to display when the alpha validation function returns false. Defaults to:
'This field should only contain letters and _'
|
VTypes | |
|
alphanumMask : RegExp
The keystroke filter mask to be applied on alphanumeric input. Defaults to:
/[a-z0-9_]/i
|
VTypes | |
|
alphanumText : String The error text to display when the alphanumeric validation function returns false. Defaults to:
'This field should o...
The error text to display when the alphanumeric validation function returns false. Defaults to:
'This field should only contain letters, numbers and _'
|
VTypes | |
|
authorizableIdMask : Object The keystroke mask to be applied on item name input. Allowed are:
Characters (a - z), digits (0 - 9), underscore (_),...
The keystroke mask to be applied on item name input. Allowed are:
Characters (a - z), digits (0 - 9), underscore (_), at sign (@) and dash (-).
Added in CQ 5.4.
|
VTypes | |
|
digitsMask : Object
The keystroke mask to be applied on digit input.
|
VTypes | |
|
digitsText : Object
The error text to display when the digit validation function returns false.
|
VTypes | |
|
emailMask : RegExp The keystroke filter mask to be applied on email input. See the email method for
information about more complex emai...
The keystroke filter mask to be applied on email input. See the email method for
information about more complex email validation. Defaults to:
/[a-z0-9_\.\-\+\'@]/i
|
VTypes | |
|
emailText : String The error text to display when the email validation function returns false. Defaults to:
'This field should be an e-...
The error text to display when the email validation function returns false. Defaults to:
'This field should be an e-mail address in the format "user@example.com"'
|
VTypes | |
|
itemnameMask : Object The keystroke mask to be applied on item name input. Allowed are:
Characters (a - z), digits (0 - 9), underscores (_)...
The keystroke mask to be applied on item name input. Allowed are:
Characters (a - z), digits (0 - 9), underscores (_) and dashes (-).
|
VTypes | |
|
itemnameText : Object
The error text to display when the item name validation function
returns false.
|
VTypes | |
|
nameMask : Object The keystroke mask to be applied on name input (spaces are allowed).
See the name method for more information on name...
The keystroke mask to be applied on name input (spaces are allowed).
See the name method for more information on name validation.
|
VTypes | |
|
nameMaskTerm : Object
The keystroke mask to be applied on name input.
See the name method for more information on name validation.
|
VTypes | |
|
nameText : Object
The error text to display when the name validation function returns false.
|
VTypes | |
|
urlText : String The error text to display when the url validation function returns false. Defaults to:
'This field should be a URL i...
The error text to display when the url validation function returns false. Defaults to:
'This field should be a URL in the format "http:/'+'/www.example.com"'
|
VTypes | |
| Method | Defined By | |
|---|---|---|
alpha( String value ) : Boolean The function used to validate alpha values
The function used to validate alpha values
Parameters:
|
VTypes | |
alphanum( String value ) : Boolean The function used to validate alphanumeric values
The function used to validate alphanumeric values
Parameters:
|
VTypes | |
authorizableId( String value ) : void The function used to validate item names.
The function used to validate item names.
Added in CQ 5.4.
Parameters:
|
VTypes | |
digits( String value ) : void The function used to validate digits.
The function used to validate digits.
Parameters:
|
VTypes | |
email( String value ) : Boolean The function used to validate email addresses. Note that this is a very basic validation -- complete
validation per ...
The function used to validate email addresses. Note that this is a very basic validation -- complete
validation per the email RFC specifications is very complex and beyond the scope of this class, although
this function can be overridden if a more comprehensive validation scheme is desired. See the validation
section of the Wikipedia article on email addresses
for additional information. This implementation is intended to validate the following emails:
'barney@example.de', 'barney.rubble@example.com', 'barney-rubble@example.coop', 'barney+rubble@example.com'
.
Parameters:
|
VTypes | |
itemname( String value ) : void The function used to validate item names.
The function used to validate item names.
Parameters:
|
VTypes | |
makeAuthorizableId( String s, String replacementChar ) : void Returns an id that is compliant with the rules set forth by the authorizableId
validator. Uppercase letters will be r...
Returns an id that is compliant with the rules set forth by the authorizableId
validator. Uppercase letters will be replaced by lowercased and illegal characters
will be replaced by the specified replace character.
Added in CQ 5.4.
Parameters:
|
VTypes | |
makeItemname( String name, String replaceChar ) : void Returns an name that is compliant with the rules set forth by the itemname
validator. Illegal characters will be repl...
Returns an name that is compliant with the rules set forth by the itemname
validator. Illegal characters will be replaced by the specified replace
character.
Added in CQ 5.4.
Parameters:
|
VTypes | |
makeName( String name, String replaceChar ) : void Returns a name that is compliant with the rules set forth by the name
validator. Illegal characters will be replaced ...
Returns a name that is compliant with the rules set forth by the name
validator. Illegal characters will be replaced by the specified replace
character.
Parameters:
|
VTypes | |
name( String value ) : void The function used to validate names. Accepted names must
be valid JCR item
names, i.e. not contain slashes, colons, ...
The function used to validate names. Accepted names must
Parameters:
|
VTypes | |
url( String value ) : Boolean The function used to validate URLs
The function used to validate URLs
Parameters:
|
VTypes | |