parsley-rails 1.1.18.0 → 1.2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,148 +3,173 @@ window.ParsleyConfig = window.ParsleyConfig || {};
3
3
  (function ($) {
4
4
  window.ParsleyConfig = $.extend( true, {}, window.ParsleyConfig, {
5
5
  validators: {
6
- es_dni: function ( val, elem, self ) {
7
- var letter, letters, number;
8
-
9
- letters = 'TRWAGMYFPDXBNJZSQVHLCKET';
10
- val = val.replace("-", "");
11
- val = val.toUpperCase();
12
- number = val.substring(0, val.length - 1);
13
- letter = val[val.length - 1];
14
-
15
- if (!/\d+/.test(number)) {
16
- return false;
17
- }
18
- if (!letters.indexOf(letter) < 0) {
19
- return false;
6
+ es_dni: function () {
7
+ return {
8
+ validate: function ( val, elem, self ) {
9
+ var letter, letters, number;
10
+
11
+ letters = 'TRWAGMYFPDXBNJZSQVHLCKET';
12
+ val = val.replace("-", "");
13
+ val = val.toUpperCase();
14
+ number = val.substring(0, val.length - 1);
15
+ letter = val[val.length - 1];
16
+
17
+ if (!/\d+/.test(number)) {
18
+ return false;
19
+ }
20
+ if (!letters.indexOf(letter) < 0) {
21
+ return false;
22
+ }
23
+ return letter == letters[parseInt(number, 10) % 23];
24
+ }
25
+ , priority: 32
20
26
  }
21
- return letter == letters[parseInt(number, 10) % 23];
22
27
  }
23
- , es_postalcode: function(val, elem, self) {
24
- var provinceCode;
25
-
26
- if (!/^\d{5}$/.test(val)) {
27
- return false;
28
- }
29
- provinceCode = parseInt(val.substring(0,2), 10);
30
- if (provinceCode > 52 || provinceCode < 1) {
31
- return false;
28
+ , es_postalcode: function () {
29
+ return {
30
+ validate: function(val, elem, self) {
31
+ var provinceCode;
32
+
33
+ if (!/^\d{5}$/.test(val)) {
34
+ return false;
35
+ }
36
+ provinceCode = parseInt(val.substring(0,2), 10);
37
+ if (provinceCode > 52 || provinceCode < 1) {
38
+ return false;
39
+ }
40
+ return true;
41
+ }
42
+ , priority: 32
32
43
  }
33
- return true;
34
44
  }
35
- , es_ssn: function(val, elem, self) {
36
- var a, b, c, code, d;
37
-
38
- val = val.replace(/[ \/-]/g, "");
39
- if (!/^\d{12}$/.test(val)) {
40
- return false;
41
- }
42
-
43
- a = val.substring(0, 2);
44
- b = val.substring(2, 10);
45
- code = val.substring(10, 12);
46
-
47
- if (parseInt(b, 10) < 10000000) {
48
- d = parseInt(b, 10) + (parseInt(a, 10) * 10000000);
49
- } else {
50
- d = a + b.replace(/0*$/, "");
45
+ , es_ssn: function () {
46
+ return {
47
+ validate: function(val, elem, self) {
48
+ var a, b, c, code, d;
49
+
50
+ val = val.replace(/[ \/-]/g, "");
51
+ if (!/^\d{12}$/.test(val)) {
52
+ return false;
53
+ }
54
+
55
+ a = val.substring(0, 2);
56
+ b = val.substring(2, 10);
57
+ code = val.substring(10, 12);
58
+
59
+ if (parseInt(b, 10) < 10000000) {
60
+ d = parseInt(b, 10) + (parseInt(a, 10) * 10000000);
61
+ } else {
62
+ d = a + b.replace(/0*$/, "");
63
+ }
64
+ c = parseInt(d) % 97;
65
+ return c === parseInt(code);
66
+ }
67
+ , priority: 32
51
68
  }
52
- c = parseInt(d) % 97;
53
- return c === parseInt(code);
54
69
  }
55
- , es_ccc: function(val, elem, self) {
56
- var account, controlCode, entity, firstCode, firstCodeMod,
57
- firstCodeResult, office, secondCode, secondCodeMod,
58
- secondCodeResult, weight, x;
59
-
60
- val = val.replace(/[ -]/g, "");
61
- if (!/\d{20}$/.test(val)) {
62
- return false;
63
- }
64
-
65
- weight = [1, 2, 4, 8, 5, 10, 9, 7, 3, 6];
66
- entity = val.substring(0, 4);
67
- office = val.substring(4, 8);
68
- controlCode = val.substring(8, 10);
69
- account = val.substr(10, 20);
70
- firstCode = "00" + entity + office;
71
- secondCode = account;
72
- firstCodeResult = 0;
73
- for (x = 0; x < 10; x++) {
74
- firstCodeResult += parseInt(firstCode[x], 10) * weight[x];
75
- }
76
- firstCodeMod = firstCodeResult % 11;
77
- firstCodeResult = 11 - firstCodeMod;
78
- if (firstCodeResult === 10) {
79
- firstCodeResult = 1;
80
- }
81
- if (firstCodeResult === 11) {
82
- firstCodeResult = 0;
83
- }
84
- secondCodeResult = 0;
85
- for (x = 0; x < 10; x++) {
86
- secondCodeResult += parseInt(secondCode[x], 10) * weight[x];
87
- }
88
- secondCodeMod = secondCodeResult % 11;
89
- secondCodeResult = 11 - secondCodeMod;
90
- if (secondCodeResult === 10) {
91
- secondCodeResult = 1;
92
- }
93
- if (secondCodeResult === 11) {
94
- secondCodeResult = 0;
95
- }
96
- if (firstCodeResult === parseInt(controlCode[0]) && secondCodeResult === parseInt(controlCode[1])) {
97
- return true;
70
+ , es_ccc: function () {
71
+ return {
72
+ validate: function(val, elem, self) {
73
+ var account, controlCode, entity, firstCode, firstCodeMod,
74
+ firstCodeResult, office, secondCode, secondCodeMod,
75
+ secondCodeResult, weight, x;
76
+
77
+ val = val.replace(/[ -]/g, "");
78
+ if (!/\d{20}$/.test(val)) {
79
+ return false;
80
+ }
81
+
82
+ weight = [1, 2, 4, 8, 5, 10, 9, 7, 3, 6];
83
+ entity = val.substring(0, 4);
84
+ office = val.substring(4, 8);
85
+ controlCode = val.substring(8, 10);
86
+ account = val.substr(10, 20);
87
+ firstCode = "00" + entity + office;
88
+ secondCode = account;
89
+ firstCodeResult = 0;
90
+ for (x = 0; x < 10; x++) {
91
+ firstCodeResult += parseInt(firstCode[x], 10) * weight[x];
92
+ }
93
+ firstCodeMod = firstCodeResult % 11;
94
+ firstCodeResult = 11 - firstCodeMod;
95
+ if (firstCodeResult === 10) {
96
+ firstCodeResult = 1;
97
+ }
98
+ if (firstCodeResult === 11) {
99
+ firstCodeResult = 0;
100
+ }
101
+ secondCodeResult = 0;
102
+ for (x = 0; x < 10; x++) {
103
+ secondCodeResult += parseInt(secondCode[x], 10) * weight[x];
104
+ }
105
+ secondCodeMod = secondCodeResult % 11;
106
+ secondCodeResult = 11 - secondCodeMod;
107
+ if (secondCodeResult === 10) {
108
+ secondCodeResult = 1;
109
+ }
110
+ if (secondCodeResult === 11) {
111
+ secondCodeResult = 0;
112
+ }
113
+ if (firstCodeResult === parseInt(controlCode[0]) && secondCodeResult === parseInt(controlCode[1])) {
114
+ return true;
115
+ }
116
+ return false;
117
+ }
118
+ , priority: 32
98
119
  }
99
- return false;
100
120
  }
101
- , es_cif: function(val, elem, self) {
102
- var oddSum, evenSum, totalSum, controlCode, controlDigit, reminder,
103
- letter, number, oddNumbers, provinceCode, x, _i, _len;
104
-
105
- val = val.replace(/-/g, "").toUpperCase();
106
-
107
- if (!/^[ABCDEFGHJKLMNPRQSUVW]\d{7}[\d[ABCDEFGHIJ]$/.test(val)) {
108
- return false;
109
- }
110
-
111
- letter = val.substring(0, 1);
112
- provinceCode = val.substring(1, 3);
113
- number = val.substring(3, 8);
114
- controlCode = val.substring(8, 9);
115
-
116
- if (/[CKLMNPQRSW]/.test(letter) && /\d/.test(controlCode)) {
117
- return false;
118
- }
119
- if (/[ABDEFGHJUV]/.test(letter) && /[A-Z]/.test(controlCode)) {
120
- return false;
121
- }
122
-
123
- oddSum = parseInt(provinceCode[1], 10) + parseInt(number[1], 10) + parseInt(number[3], 10);
124
-
125
- evenSum = 0;
126
- oddNumbers = [
127
- parseInt(provinceCode[0], 10),
128
- parseInt(number[0], 10),
129
- parseInt(number[2], 10),
130
- parseInt(number[4], 10)
131
- ];
132
- for (_i = 0, _len = oddNumbers.length; _i < _len; _i++) {
133
- number = oddNumbers[_i];
134
- x = number * 2;
135
- if (x >= 10) {
136
- x = (x % 10) + 1;
121
+ , es_cif: function () {
122
+ return {
123
+ validate: function(val, elem, self) {
124
+ var oddSum, evenSum, totalSum, controlCode, controlDigit, reminder,
125
+ letter, number, oddNumbers, provinceCode, x, _i, _len;
126
+
127
+ val = val.replace(/-/g, "").toUpperCase();
128
+
129
+ if (!/^[ABCDEFGHJKLMNPRQSUVW]\d{7}[\d[ABCDEFGHIJ]$/.test(val)) {
130
+ return false;
131
+ }
132
+
133
+ letter = val.substring(0, 1);
134
+ provinceCode = val.substring(1, 3);
135
+ number = val.substring(3, 8);
136
+ controlCode = val.substring(8, 9);
137
+
138
+ if (/[CKLMNPQRSW]/.test(letter) && /\d/.test(controlCode)) {
139
+ return false;
140
+ }
141
+ if (/[ABDEFGHJUV]/.test(letter) && /[A-Z]/.test(controlCode)) {
142
+ return false;
143
+ }
144
+
145
+ oddSum = parseInt(provinceCode[1], 10) + parseInt(number[1], 10) + parseInt(number[3], 10);
146
+
147
+ evenSum = 0;
148
+ oddNumbers = [
149
+ parseInt(provinceCode[0], 10),
150
+ parseInt(number[0], 10),
151
+ parseInt(number[2], 10),
152
+ parseInt(number[4], 10)
153
+ ];
154
+ for (_i = 0, _len = oddNumbers.length; _i < _len; _i++) {
155
+ number = oddNumbers[_i];
156
+ x = number * 2;
157
+ if (x >= 10) {
158
+ x = (x % 10) + 1;
159
+ }
160
+ evenSum += x;
161
+ }
162
+ totalSum = oddSum + evenSum;
163
+ reminder = totalSum % 10;
164
+ if (reminder !== 0) { controlDigit = 10 - reminder; } else { controlDigit = 0; }
165
+
166
+ if (controlCode !== controlDigit.toString() && 'JABCDEFGHI'[controlDigit] !== controlCode) {
167
+ return false;
168
+ }
169
+ return true;
137
170
  }
138
- evenSum += x;
139
- }
140
- totalSum = oddSum + evenSum;
141
- reminder = totalSum % 10;
142
- if (reminder !== 0) { controlDigit = 10 - reminder; } else { controlDigit = 0; }
143
-
144
- if (controlCode !== controlDigit.toString() && 'JABCDEFGHI'[controlDigit] !== controlCode) {
145
- return false;
171
+ , priority: 32
146
172
  }
147
- return true;
148
173
  }
149
174
  }
150
175
  , messages: {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parsley-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.18.0
4
+ version: 1.2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jiri Pospisil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-27 00:00:00.000000000 Z
11
+ date: 2013-11-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Parsley.js bundled for Rails Asset Pipeline
14
14
  email: