diff --git a/validate/_base.js b/validate/_base.js index 589f970fbd..876247c095 100644 --- a/validate/_base.js +++ b/validate/_base.js @@ -5,21 +5,18 @@ define([ "./regexp" // additional expressions ], function(lang, regexp, number, xregexp) { - var validate = lang.getObject("dojox.validate", true); - /*===== - validate = dojox.validate; - =====*/ +var validate = lang.getObject("dojox.validate", true); -validate.isText = function(/*String*/value, /*Object?*/flags){ +validate.isText = function(value, flags){ // summary: - // Checks if a string has non whitespace characters. - // Parameters allow you to constrain the length. - // - // value: A string - // flags: {length: Number, minlength: Number, maxlength: Number} - // flags.length If set, checks if there are exactly flags.length number of characters. - // flags.minlength If set, checks if there are at least flags.minlength number of characters. - // flags.maxlength If set, checks if there are at most flags.maxlength number of characters. + // Checks if a string has non whitespace characters. + // Parameters allow you to constrain the length. + // value: String + // flags: Object? + // {length: Number, minlength: Number, maxlength: Number} + // - flags.length If set, checks if there are exactly flags.length number of characters. + // - flags.minlength If set, checks if there are at least flags.minlength number of characters. + // - flags.maxlength If set, checks if there are at most flags.maxlength number of characters. flags = (typeof flags == "object") ? flags : {}; @@ -36,16 +33,16 @@ validate.isText = function(/*String*/value, /*Object?*/flags){ }; validate._isInRangeCache = {}; -validate.isInRange = function(/*String*/value, /*Object?*/flags){ +validate.isInRange = function(value, flags){ // summary: - // Validates whether a string denoting a number - // is between a max and min. - // - // value: A string - // flags: {max:Number, min:Number, decimal:String} - // flags.max A number, which the value must be less than or equal to for the validation to be true. - // flags.min A number, which the value must be greater than or equal to for the validation to be true. - // flags.decimal The character used for the decimal point. Default is ".". + // Validates whether a string denoting a number + // is between a max and min. + // value: String + // flags: Object? + // {max:Number, min:Number, decimal:String} + // - flags.max A number, which the value must be less than or equal to for the validation to be true. + // - flags.min A number, which the value must be greater than or equal to for the validation to be true. + // - flags.decimal The character used for the decimal point. Default is ".". value = number.parse(value, flags); if(isNaN(value)){ @@ -70,9 +67,9 @@ validate.isInRange = function(/*String*/value, /*Object?*/flags){ }; -validate.isNumberFormat = function(/* String */value, /* Object? */flags){ - // summary: Validates any sort of number based format - // +validate.isNumberFormat = function(value, flags){ + // summary: + // Validates any sort of number based format // description: // Validates any sort of number based format. Use it for phone numbers, // social security numbers, zip-codes, etc. The value can be validated @@ -89,18 +86,12 @@ validate.isNumberFormat = function(/* String */value, /* Object? */flags){ // | "###-##-####" -> 506-82-1089 i.e. social security number // | "#####-####" -> 98225-1649 i.e. zip code // - // value: A string - // + // value: String // flags: Object? - // FIXME: make pseudo-object for this - // format: String - // - // flags.format A string or an Array of strings for multiple formats. - // + // - flags.format A string or an Array of strings for multiple formats. // example: - // | // returns true: - // | dojox.validate.isNumberFormat("123-45", { format:"###-##" }); - // + // | // returns true: + // | dojox.validate.isNumberFormat("123-45", { format:"###-##" }); // example: // Check Multiple formats: // | dojox.validate.isNumberFormat("123-45", { @@ -113,7 +104,8 @@ validate.isNumberFormat = function(/* String */value, /* Object? */flags){ }; validate.isValidLuhn = function(/* String */value){ - // summary: Validate a String value against the Luhn algorithm. + // summary: + // Validate a String value against the Luhn algorithm. // description: // Validate a String value against the Luhn algorithm to verify // its integrity. diff --git a/validate/br.js b/validate/br.js index ac7907bbc0..e6be2765dc 100755 --- a/validate/br.js +++ b/validate/br.js @@ -4,7 +4,6 @@ var br = lang.getObject("br", true, validate); br.isValidCnpj = function(/*String*/value){ // summary: // Validates a CNPJ/CGC number - // // value: String // The CNPJ/CGC number in ##.###.###/####-##, ########/####-##, // ############-## or ############## format @@ -78,9 +77,10 @@ br.isValidCnpj = function(/*String*/value){ }; br.computeCnpjDv = function(/*String*/value){ - // summary: Generate the DV code (checksum part) for a Cnpj number - // - // value: The CGC number in ##.###.###/#### or ############ format + // summary: + // Generate the DV code (checksum part) for a Cnpj number + // value: + // The CGC number in ##.###.###/#### or ############ format if(!lang.isString(value)){ if(!value){ return ""; @@ -141,7 +141,6 @@ br.computeCnpjDv = function(/*String*/value){ br.isValidCpf = function(/*String*/value){ // summary: // Validates a CPF number - // // value: String // The CPF number in #########-## or ###########, // format @@ -216,7 +215,6 @@ br.isValidCpf = function(/*String*/value){ br.computeCpfDv = function(/*String*/value){ // summary: // Generate the DV code (checksum part) for a CPF number - // // value: String // The CPF number in ######### format if(!lang.isString(value)){ diff --git a/validate/ca.js b/validate/ca.js index e991d18d7e..d1b4651c7e 100644 --- a/validate/ca.js +++ b/validate/ca.js @@ -1,49 +1,49 @@ define(["dojo/_base/lang", "./_base", "./regexp", "./us"], function(lang, validate, xregexp, us){ -/*===== - - dojox.validate.ca = { - // summary: Module which includes Canadian-specific methods for dojox.validate - } +var ca = lang.getObject("ca", true, validate); +/*===== +ca = { + // summary: + // Module which includes Canadian-specific methods for dojox.validate +}; =====*/ -var ca = lang.getObject("ca", true, validate); lang.mixin(ca, { isPhoneNumber: function(/* String */value){ - // summary: Validates Canadian 10-digit phone number for several common formats + // summary: + // Validates Canadian 10-digit phone number for several common formats return us.isPhoneNumber(value); // Boolean }, isProvince: function(/* String[2] */value) { - // summary: Validates Canadian province abbreviations (2 characters) + // summary: + // Validates Canadian province abbreviations (2 characters) var re = new RegExp("^" + xregexp.ca.province() + "$", "i"); return re.test(value); // Boolean }, isSocialInsuranceNumber: function(/* String */value) { - // summary: Validates Canadian 9 digit social insurance number for several + // summary: + // Validates Canadian 9 digit social insurance number for several // common formats - // // description: // Validates Canadian 9 digit social insurance number for several // common formats. This routine only pattern matches and does not // use the Luhn Algorithm to validate number. - // var flags = { format: [ "###-###-###", "### ### ###", "#########" ]}; return validate.isNumberFormat(value, flags); // Boolean }, isPostalCode: function(value) { - // summary: Validates Canadian 6 digit postal code - // + // summary: + // Validates Canadian 6 digit postal code // description: // Validates Canadian 6 digit postal code. // Canadian postal codes are in the format ANA NAN, // where A is a letter and N is a digit, with a space // separating the third and fourth characters. - // var re = new RegExp("^" + xregexp.ca.postalCode() + "$", "i"); return re.test(value); // Boolean } diff --git a/validate/check.js b/validate/check.js index f8a571bb85..465976e7ed 100644 --- a/validate/check.js +++ b/validate/check.js @@ -2,11 +2,6 @@ define(["dojo/_base/kernel", "dojo/_base/lang", "./_base"], function(kernel, lang, validate){ kernel.experimental("dojox.validate.check"); -/*===== - - validate = dojox.validate; - -=====*/ /** FIXME: How much does this overlap with dojox.form.Manager and friends? @@ -75,15 +70,16 @@ kernel.experimental("dojox.validate.check"); */ validate.check = function(/*HTMLFormElement*/form, /*Object*/profile){ - // summary: validates user input of an HTML form based on input profile - // + // summary: + // validates user input of an HTML form based on input profile // description: - // returns an object that contains several methods summarizing the results of the validation - // - // form: form to be validated - // profile: specifies how the form fields are to be validated - // {trim:Array, uppercase:Array, lowercase:Array, ucfirst:Array, digit:Array, - // required:Array, dependencies:Object, constraints:Object, confirm:Object} + // returns an object that contains several methods summarizing the results of the validation + // form: + // form to be validated + // profile: + // specifies how the form fields are to be validated + // {trim:Array, uppercase:Array, lowercase:Array, ucfirst:Array, digit:Array, + // required:Array, dependencies:Object, constraints:Object, confirm:Object} // Essentially private properties of results object var missing = []; @@ -300,24 +296,27 @@ validate.check = function(/*HTMLFormElement*/form, /*Object*/profile){ //TODO: evaluateConstraint doesn't use profile or fieldName args? validate.evaluateConstraint=function(profile, /*Array*/constraint, fieldName, elem){ // summary: - // Evaluates dojo.validate.check() constraints that are specified as array - // arguments - // - // description: The arrays are expected to be in the format of: - // constraints:{ - // fieldName: [functionToCall, param1, param2, etc.], - // fieldName: [[functionToCallFirst, param1],[functionToCallSecond,param2]] - // } + // Evaluates dojo.validate.check() constraints that are specified as array + // arguments + // description: + // The arrays are expected to be in the format of: + // | constraints:{ + // | fieldName: [functionToCall, param1, param2, etc.], + // | fieldName: [[functionToCallFirst, param1],[functionToCallSecond,param2]] + // | } // - // This function evaluates a single array function in the format of: + // This function evaluates a single array function in the format of: // [functionName, argument1, argument2, etc] // - // The function will be parsed out and evaluated against the incoming parameters. - // - // profile: The dojo.validate.check() profile that this evaluation is against. - // constraint: The single [] array of function and arguments for the function. - // fieldName: The form dom name of the field being validated. - // elem: The form element field. + // The function will be parsed out and evaluated against the incoming parameters. + // profile: + // The dojo.validate.check() profile that this evaluation is against. + // constraint: + // The single [] array of function and arguments for the function. + // fieldName: + // The form dom name of the field being validated. + // elem: + // The form element field. var isValidSomething = constraint[0]; var params = constraint.slice(1); diff --git a/validate/creditCard.js b/validate/creditCard.js index b979c27d93..a23d7e5f66 100644 --- a/validate/creditCard.js +++ b/validate/creditCard.js @@ -1,21 +1,17 @@ define(["dojo/_base/lang", "./_base"], function(lang, validate){ -/*===== - dojox.validate.creditCard = { +/*===== + return { // summary: // Module provides validation functions for Credit Cards, using account number - // rules in conjunction with the Luhn algorigthm, with a plugable card info database. + // rules in conjunction with the Luhn algorigthm, with a pluggable card info database. }; - - validate = dojox.validate; - =====*/ validate._cardInfo = { - // summary: A dictionary list of credit card abbreviations - // + // summary: + // A dictionary list of credit card abbreviations // description: - // // A hash of valid CC abbreviations and regular expressions // // mc: Mastercard @@ -28,7 +24,7 @@ validate._cardInfo = { // jcb: JCB // er: Enroute // - // example: + // example: // Define your own card, gift-card, whatever. Starts with 7, // is 15 total length. // | dojo.mixin(dojox.validate._cardInfo, { @@ -47,19 +43,16 @@ validate._cardInfo = { }; validate.isValidCreditCard = function(value, ccType){ - // summary: Validate a credit card number by type with Luhn checking. - // + // summary: + // Validate a credit card number by type with Luhn checking. // description: // Checks if a credit card type matches the # scheme in a passed value, and if // the Luhn checksum is accurate (unless its an Enroute card, in which case // the checkSum is skipped), returning a Boolean to check against. - // // value: String|Int // A Value (credit card number) to validate - // // ccType: String // A credit-card abbreviation. - // // example: // | if(dojox.validate.isValidCreditCard("12345", "mc")){ // | console.log('inconceivable'); @@ -72,10 +65,8 @@ validate.isValidCreditCard = function(value, ccType){ validate.isValidCreditCardNumber = function(value, ccType){ // summary: // Checks if value matches the pattern for that card or any card types if none is specified - // // value: String|Int // CC #, white spaces and dashes are ignored - // // ccType: String? // One of the abbreviation values in `dojox.validate._cardInfo` -- // if Omitted, function returns a `|` delimited string of matching card types, @@ -100,10 +91,6 @@ validate.isValidCreditCardNumber = function(value, ccType){ validate.isValidCvv = function(/* String|Int */value, /* String */ccType) { // summary: // Validate the security code (CCV) for a passed credit-card type. - // - // description: - // - // value: if(!lang.isString(value)){ value = String(value); @@ -124,5 +111,6 @@ validate.isValidCvv = function(/* String|Int */value, /* String */ccType) { return !!format && value.length && validate.isNumberFormat(value, { format: format }); // Boolean }; +// TODO: return functions defined in this module, rather than sticking them into "validate" return validate; }); diff --git a/validate/isbn.js b/validate/isbn.js index 9553f9b6ee..40d4522c27 100644 --- a/validate/isbn.js +++ b/validate/isbn.js @@ -1,15 +1,8 @@ define(["dojo/_base/lang", "./_base"], function(lang, validate){ -// summary: Provides ISBN validation functions in `dojox.validate` -// - -/*===== - - validate = dojox.validate; - -=====*/ validate.isValidIsbn = function(/* String */value) { - // summary: Validate ISBN-10 or ISBN-13 based on the length of value + // summary: + // Validate ISBN-10 or ISBN-13 based on the length of value // value: String // An ISBN to validate // returns: Boolean diff --git a/validate/regexp.js b/validate/regexp.js index 058be5f157..52944d393c 100644 --- a/validate/regexp.js +++ b/validate/regexp.js @@ -4,25 +4,25 @@ define(["dojo/_base/lang", "dojo/regexp", "dojox/main"], var dxregexp = lang.getObject("validate.regexp", true, dojox); dxregexp = dojox.validate.regexp = { - ipAddress: function(/*Object?*/flags){ - // summary: Builds a RE that matches an IP Address - // + ipAddress: function(flags){ + // summary: + // Builds a RE that matches an IP Address // description: - // Supports 5 formats for IPv4: dotted decimal, dotted hex, dotted octal, decimal and hexadecimal. - // Supports 2 formats for Ipv6. - // - // flags: An object. All flags are boolean with default = true. - // flags.allowDottedDecimal Example, 207.142.131.235. No zero padding. - // flags.allowDottedHex Example, 0x18.0x11.0x9b.0x28. Case insensitive. Zero padding allowed. - // flags.allowDottedOctal Example, 0030.0021.0233.0050. Zero padding allowed. - // flags.allowDecimal Example, 3482223595. A decimal number between 0-4294967295. - // flags.allowHex Example, 0xCF8E83EB. Hexadecimal number between 0x0-0xFFFFFFFF. - // Case insensitive. Zero padding allowed. - // flags.allowIPv6 IPv6 address written as eight groups of four hexadecimal digits. + // Supports 5 formats for IPv4: dotted decimal, dotted hex, dotted octal, decimal and hexadecimal. + // Supports 2 formats for Ipv6. + // flags: Object? + // All flags are boolean with default = true. + // - flags.allowDottedDecimal Example, 207.142.131.235. No zero padding. + // - flags.allowDottedHex Example, 0x18.0x11.0x9b.0x28. Case insensitive. Zero padding allowed. + // - flags.allowDottedOctal Example, 0030.0021.0233.0050. Zero padding allowed. + // - flags.allowDecimal Example, 3482223595. A decimal number between 0-4294967295. + // - flags.allowHex Example, 0xCF8E83EB. Hexadecimal number between 0x0-0xFFFFFFFF. + // Case insensitive. Zero padding allowed. + // - flags.allowIPv6 IPv6 address written as eight groups of four hexadecimal digits. // FIXME: ipv6 can be written multiple ways IIRC - // flags.allowHybrid IPv6 address written as six groups of four hexadecimal digits - // followed by the usual 4 dotted decimal digit notation of IPv4. x:x:x:x:x:x:d.d.d.d + // - flags.allowHybrid IPv6 address written as six groups of four hexadecimal digits + // - followed by the usual 4 dotted decimal digit notation of IPv4. x:x:x:x:x:x:d.d.d.d // assign default values to missing paramters flags = (typeof flags == "object") ? flags : {}; @@ -82,15 +82,17 @@ dxregexp = dojox.validate.regexp = { return ipAddressRE; // String }, - host: function(/*Object?*/flags){ - // summary: Builds a RE that matches a host - // description: A host is a named host (A-z0-9_- but not starting with -), a domain name or an IP address, possibly followed by a port number. - // flags: An object. - // flags.allowNamed Allow a named host for local networks. Default is false. - // flags.allowIP Allow an IP address for hostname. Default is true. - // flags.allowLocal Allow the host to be "localhost". Default is false. - // flags.allowPort Allow a port number to be present. Default is true. - // flags in regexp.ipAddress can be applied. + host: function(flags){ + // summary: + // Builds a RE that matches a host + // description: + // A host is a named host (A-z0-9_- but not starting with -), a domain name or an IP address, possibly followed by a port number. + // flags: Object? + // - flags.allowNamed Allow a named host for local networks. Default is false. + // - flags.allowIP Allow an IP address for hostname. Default is true. + // - flags.allowLocal Allow the host to be "localhost". Default is false. + // - flags.allowPort Allow a port number to be present. Default is true. + // - flags in regexp.ipAddress can be applied. // assign default values to missing paramters flags = (typeof flags == "object") ? flags : {}; @@ -117,14 +119,14 @@ dxregexp = dojox.validate.regexp = { }, - url: function(/*Object?*/flags){ - // summary: Builds a regular expression that matches a URL - // - // flags: An object - // flags.scheme Can be true, false, or [true, false]. - // This means: required, not allowed, or match either one. - // flags in regexp.host can be applied. - // flags in regexp.ipAddress can be applied. + url: function(flags){ + // summary: + // Builds a regular expression that matches a URL + // flags: Object? + // - flags.scheme Can be true, false, or [true, false]. + // - This means: required, not allowed, or match either one. + // - flags in regexp.host can be applied. + // - flags in regexp.ipAddress can be applied. // assign default values to missing paramters flags = (typeof flags == "object") ? flags : {}; @@ -141,14 +143,13 @@ dxregexp = dojox.validate.regexp = { return protocolRE + dxregexp.host(flags) + pathRE; }, - emailAddress: function(/*Object?*/flags){ - - // summary: Builds a regular expression that matches an email address - // - // flags: An object - // flags.allowCruft Allow address like . Default is false. - // flags in regexp.host can be applied. - // flags in regexp.ipAddress can be applied. + emailAddress: function(flags){ + // summary: + // Builds a regular expression that matches an email address + // flags: Object? + // - flags.allowCruft Allow address like . Default is false. + // - flags in regexp.host can be applied. + // - flags in regexp.ipAddress can be applied. // assign default values to missing paramters flags = (typeof flags == "object") ? flags : {}; @@ -169,14 +170,14 @@ dxregexp = dojox.validate.regexp = { return emailAddressRE; // String }, - emailAddressList: function(/*Object?*/flags){ - // summary: Builds a regular expression that matches a list of email addresses. - // - // flags: An object. - // flags.listSeparator The character used to separate email addresses. Default is ";", ",", "\n" or " ". - // flags in regexp.emailAddress can be applied. - // flags in regexp.host can be applied. - // flags in regexp.ipAddress can be applied. + emailAddressList: function(flags){ + // summary: + // Builds a regular expression that matches a list of email addresses. + // flags: Object? + // - flags.listSeparator The character used to separate email addresses. Default is ";", ",", "\n" or " ". + // - flags in regexp.emailAddress can be applied. + // - flags in regexp.host can be applied. + // - flags in regexp.ipAddress can be applied. // assign default values to missing paramters flags = (typeof flags == "object") ? flags : {}; @@ -190,25 +191,26 @@ dxregexp = dojox.validate.regexp = { return emailAddressListRE; // String }, - numberFormat: function(/*Object?*/flags){ - // summary: Builds a regular expression to match any sort of number based format + numberFormat: function(flags){ + // summary: + // Builds a regular expression to match any sort of number based format // description: - // Use this method for phone numbers, social security numbers, zip-codes, etc. - // The RE can match one format or one of multiple formats. + // Use this method for phone numbers, social security numbers, zip-codes, etc. + // The RE can match one format or one of multiple formats. // - // Format - // # Stands for a digit, 0-9. - // ? Stands for an optional digit, 0-9 or nothing. - // All other characters must appear literally in the expression. + // Format + // - # Stands for a digit, 0-9. + // - ? Stands for an optional digit, 0-9 or nothing. + // - All other characters must appear literally in the expression. // - // Example - // "(###) ###-####" -> (510) 542-9742 - // "(###) ###-#### x#???" -> (510) 542-9742 x153 - // "###-##-####" -> 506-82-1089 i.e. social security number - // "#####-####" -> 98225-1649 i.e. zip code + // example: + // - "(###) ###-####" - -> (510) 542-9742 + // - "(###) ###-#### x#???" -> (510) 542-9742 x153 + // - "###-##-####" - - -> 506-82-1089 - i.e. social security number + // - "#####-####" - - -> 98225-1649 - - i.e. zip code // - // flags: An object - // flags.format A string or an Array of strings for multiple formats. + // flags: Object? + // - flags.format A string or an Array of strings for multiple formats. // assign default values to missing paramters flags = (typeof flags == "object") ? flags : {}; @@ -244,13 +246,12 @@ dxregexp = dojox.validate.regexp = { }, us:{ - - state: function(/*Object?*/flags){ - // summary: A regular expression to match US state and territory abbreviations - // - // flags: An object. - // flags.allowTerritories Allow Guam, Puerto Rico, etc. Default is true. - // flags.allowMilitary Allow military 'states', e.g. Armed Forces Europe (AE). Default is true. + state: function(flags){ + // summary: + // A regular expression to match US state and territory abbreviations + // flags: Object? + // - flags.allowTerritories Allow Guam, Puerto Rico, etc. Default is true. + // - flags.allowMilitary Allow military 'states', e.g. Armed Forces Europe (AE). Default is true. // assign default values to missing paramters flags = (typeof flags == "object") ? flags : {}; diff --git a/validate/us.js b/validate/us.js index 8669cbe079..dbee1d568b 100644 --- a/validate/us.js +++ b/validate/us.js @@ -2,11 +2,12 @@ define(["dojo/_base/lang", "./_base", "./regexp"], function(lang, validate, xregexp){ var us = lang.getObject("us", true, validate); -us.isState = function(/*String*/value, /*Object?*/flags){ - // summary: Validates US state and territory abbreviations. - // - // value: A two character string - // flags: An object +us.isState = function(value, flags){ + // summary: + // Validates US state and territory abbreviations. + // value: String + // A two character string + // flags: Object? // flags.allowTerritories Allow Guam, Puerto Rico, etc. Default is true. // flags.allowMilitary Allow military 'states', e.g. Armed Forces Europe (AE). Default is true. @@ -15,8 +16,10 @@ us.isState = function(/*String*/value, /*Object?*/flags){ }; us.isPhoneNumber = function(/*String*/value){ - // summary: Validates 10 US digit phone number for several common formats - // value: The telephone number string + // summary: + // Validates 10 US digit phone number for several common formats + // value: + // The telephone number string var flags = { format: [ @@ -39,7 +42,8 @@ us.isPhoneNumber = function(/*String*/value){ }; us.isSocialSecurityNumber = function(/*String*/value){ - // summary: Validates social security number + // summary: + // Validates social security number var flags = { format: [ "###-##-####", @@ -51,7 +55,8 @@ us.isSocialSecurityNumber = function(/*String*/value){ }; us.isZipCode = function(/*String*/value){ - // summary: Validates U.S. zip-code + // summary: + // Validates U.S. zip-code var flags = { format: [ "#####-####", diff --git a/validate/web.js b/validate/web.js index b16ef6949b..4502ceb932 100644 --- a/validate/web.js +++ b/validate/web.js @@ -1,84 +1,80 @@ define(["./_base", "./regexp"], function(validate, xregexp){ -/*===== - - validate = dojox.validate; - -=====*/ - -validate.isIpAddress = function(/*String*/value, /*Object?*/flags) { - // summary: Validates an IP address - // +validate.isIpAddress = function(value, flags) { + // summary: + // Validates an IP address // description: - // Supports 5 formats for IPv4: dotted decimal, dotted hex, dotted octal, decimal and hexadecimal. - // Supports 2 formats for Ipv6. - // - // value: A string. - // flags: An object. All flags are boolean with default = true. - // flags.allowDottedDecimal Example, 207.142.131.235. No zero padding. - // flags.allowDottedHex Example, 0x18.0x11.0x9b.0x28. Case insensitive. Zero padding allowed. - // flags.allowDottedOctal Example, 0030.0021.0233.0050. Zero padding allowed. - // flags.allowDecimal Example, 3482223595. A decimal number between 0-4294967295. - // flags.allowHex Example, 0xCF8E83EB. Hexadecimal number between 0x0-0xFFFFFFFF. - // Case insensitive. Zero padding allowed. - // flags.allowIPv6 IPv6 address written as eight groups of four hexadecimal digits. - // flags.allowHybrid IPv6 address written as six groups of four hexadecimal digits - // followed by the usual 4 dotted decimal digit notation of IPv4. x:x:x:x:x:x:d.d.d.d + // Supports 5 formats for IPv4: dotted decimal, dotted hex, dotted octal, decimal and hexadecimal. + // Supports 2 formats for Ipv6. + // value: String + // flags: Object? + // All flags are boolean with default = true. + // - flags.allowDottedDecimal Example, 207.142.131.235. No zero padding. + // - flags.allowDottedHex Example, 0x18.0x11.0x9b.0x28. Case insensitive. Zero padding allowed. + // - flags.allowDottedOctal Example, 0030.0021.0233.0050. Zero padding allowed. + // - flags.allowDecimal Example, 3482223595. A decimal number between 0-4294967295. + // - flags.allowHex Example, 0xCF8E83EB. Hexadecimal number between 0x0-0xFFFFFFFF. + // Case insensitive. Zero padding allowed. + // - flags.allowIPv6 IPv6 address written as eight groups of four hexadecimal digits. + // - flags.allowHybrid IPv6 address written as six groups of four hexadecimal digits + // followed by the usual 4 dotted decimal digit notation of IPv4. x:x:x:x:x:x:d.d.d.d var re = new RegExp("^" + xregexp.ipAddress(flags) + "$", "i"); return re.test(value); // Boolean }; -validate.isUrl = function(/*String*/value, /*Object?*/flags) { - // summary: Checks if a string could be a valid URL - // value: A string - // flags: An object - // flags.scheme Can be true, false, or [true, false]. - // This means: required, not allowed, or either. - // flags in regexp.host can be applied. - // flags in regexp.ipAddress can be applied. - // flags in regexp.tld can be applied. +validate.isUrl = function(value, flags) { + // summary: + // Checks if a string could be a valid URL + // value: String + // flags: Object? + // - flags.scheme Can be true, false, or [true, false]. + // This means: required, not allowed, or either. + // - flags in regexp.host can be applied. + // - flags in regexp.ipAddress can be applied. + // - flags in regexp.tld can be applied. var re = new RegExp("^" + xregexp.url(flags) + "$", "i"); return re.test(value); // Boolean }; -validate.isEmailAddress = function(/*String*/value, /*Object?*/flags) { - // summary: Checks if a string could be a valid email address - // - // value: A string - // flags: An object - // flags.allowCruft Allow address like . Default is false. - // flags in regexp.host can be applied. - // flags in regexp.ipAddress can be applied. - // flags in regexp.tld can be applied. +validate.isEmailAddress = function(value, flags) { + // summary: + // Checks if a string could be a valid email address + // value: String + // flags: Object? + // - flags.allowCruft Allow address like . Default is false. + // - flags in regexp.host can be applied. + // - flags in regexp.ipAddress can be applied. + // - flags in regexp.tld can be applied. var re = new RegExp("^" + xregexp.emailAddress(flags) + "$", "i"); return re.test(value); // Boolean }; -validate.isEmailAddressList = function(/*String*/value, /*Object?*/flags) { - // summary: Checks if a string could be a valid email address list. - // - // value: A string. - // flags: An object. - // flags.listSeparator The character used to separate email addresses. Default is ";", ",", "\n" or " ". - // flags in regexp.emailAddress can be applied. - // flags in regexp.host can be applied. - // flags in regexp.ipAddress can be applied. - // flags in regexp.tld can be applied. +validate.isEmailAddressList = function(value, flags) { + // summary: + // Checks if a string could be a valid email address list. + // value: String + // flags: Object? + // - flags.listSeparator The character used to separate email addresses. Default is ";", ",", "\n" or " ". + // - flags in regexp.emailAddress can be applied. + // - flags in regexp.host can be applied. + // - flags in regexp.ipAddress can be applied. + // - flags in regexp.tld can be applied. var re = new RegExp("^" + xregexp.emailAddressList(flags) + "$", "i"); return re.test(value); // Boolean }; -validate.getEmailAddressList = function(/*String*/value, /*Object?*/flags) { - // summary: Check if value is an email address list. If an empty list - // is returned, the value didn't pass the test or it was empty. - // - // value: A string - // flags: An object (same as dojo.validate.isEmailAddressList) +validate.getEmailAddressList = function(value, flags) { + // summary: + // Check if value is an email address list. If an empty list + // is returned, the value didn't pass the test or it was empty. + // value: String + // flags: Object? + // An object (same as dojo.validate.isEmailAddressList) if(!flags) { flags = {}; } if(!flags.listSeparator) { flags.listSeparator = "\\s;,"; }