[483] | 1 | define(["dojo/_base/lang", "./_base", "./regexp", "./us"], |
---|
| 2 | function(lang, validate, xregexp, us){ |
---|
| 3 | |
---|
| 4 | var ca = lang.getObject("ca", true, validate); |
---|
| 5 | /*===== |
---|
| 6 | ca = { |
---|
| 7 | // summary: |
---|
| 8 | // Module which includes Canadian-specific methods for dojox.validate |
---|
| 9 | }; |
---|
| 10 | =====*/ |
---|
| 11 | |
---|
| 12 | lang.mixin(ca, { |
---|
| 13 | |
---|
| 14 | isPhoneNumber: function(/* String */value){ |
---|
| 15 | // summary: |
---|
| 16 | // Validates Canadian 10-digit phone number for several common formats |
---|
| 17 | return us.isPhoneNumber(value); // Boolean |
---|
| 18 | }, |
---|
| 19 | |
---|
| 20 | isProvince: function(/* String[2] */value) { |
---|
| 21 | // summary: |
---|
| 22 | // Validates Canadian province abbreviations (2 characters) |
---|
| 23 | var re = new RegExp("^" + xregexp.ca.province() + "$", "i"); |
---|
| 24 | return re.test(value); // Boolean |
---|
| 25 | }, |
---|
| 26 | |
---|
| 27 | isSocialInsuranceNumber: function(/* String */value) { |
---|
| 28 | // summary: |
---|
| 29 | // Validates Canadian 9 digit social insurance number for several |
---|
| 30 | // common formats |
---|
| 31 | // description: |
---|
| 32 | // Validates Canadian 9 digit social insurance number for several |
---|
| 33 | // common formats. This routine only pattern matches and does not |
---|
| 34 | // use the Luhn Algorithm to validate number. |
---|
| 35 | var flags = { format: [ "###-###-###", "### ### ###", "#########" ]}; |
---|
| 36 | return validate.isNumberFormat(value, flags); // Boolean |
---|
| 37 | }, |
---|
| 38 | |
---|
| 39 | isPostalCode: function(value) { |
---|
| 40 | // summary: |
---|
| 41 | // Validates Canadian 6 digit postal code |
---|
| 42 | // description: |
---|
| 43 | // Validates Canadian 6 digit postal code. |
---|
| 44 | // Canadian postal codes are in the format ANA NAN, |
---|
| 45 | // where A is a letter and N is a digit, with a space |
---|
| 46 | // separating the third and fourth characters. |
---|
| 47 | var re = new RegExp("^" + xregexp.ca.postalCode() + "$", "i"); |
---|
| 48 | return re.test(value); // Boolean |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | }); |
---|
| 52 | |
---|
| 53 | return ca; |
---|
| 54 | }); |
---|