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