Ext.define('Ext.form.field.VTypes', (function(){
var alpha = /^[a-zA-Z_]+$/,
alphanum = /^[a-zA-Z0-9_]+$/,
email = /^(\w+)([\-+.][\w]+)*@(\w[\-\w]*\.){1,5}([A-Za-z]){2,6}$/,
url = /(((^https?)|(^ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
// All these messages and functions are configurable
return {
singleton: true,
alternateClassName: 'Ext.form.VTypes',
/**
* 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][1] 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`
*
* [1]: http:
*
* @param {String} value The email address
* @return {Boolean} true if the RegExp test passed, and false if not.
*/
'email' : function(v){
return email.test(v);
},
'emailText' : 'This field should be an e-mail address in the format "user@example.com"',
'emailMask' : /[a-z0-9_\.\-@\+]/i,
'url' : function(v){
return url.test(v);
},
'urlText' : 'This field should be a URL in the format "http:/'+'/www.example.com"',
'alpha' : function(v){
return alpha.test(v);
},
'alphaText' : 'This field should only contain letters and _',
'alphaMask' : /[a-z_]/i,
'alphanum' : function(v){
return alphanum.test(v);
},
'alphanumText' : 'This field should only contain letters, numbers and _',
'alphanumMask' : /[a-z0-9_]/i
};
}()));