client_side_validations 3.2.6 → 3.2.7
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38fd5c8616f9660f50a6a43b5ae101489458fed8
|
4
|
+
data.tar.gz: 2462d48679c9fe78adf342c81463ad119856c6c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 109b26253fa04aa9989f449bc0fce107a42bf87e69926229589253dc45720f32973972aa7cd82f461846cfa1c73441eddeae19d0057977d54d3797fc2f808802
|
7
|
+
data.tar.gz: 6648217c328aef0e74e88be8aaa5111a9d22df5eeb4c3a5ce48ab45f6792a64d2b01433be5b5bd592b93d3e504d1f2a1822a9db4c4decfdd4b3dc7049c2b8344
|
@@ -13,31 +13,23 @@ module ClientSideValidations::ActiveRecord
|
|
13
13
|
|
14
14
|
t = klass.arel_table
|
15
15
|
|
16
|
+
sql = []
|
16
17
|
if params[:case_sensitive] == 'true'
|
17
|
-
if t.engine.connection.adapter_name =~ /^mysql/i
|
18
|
-
|
19
|
-
else
|
20
|
-
relation = t[attribute].eq(value)
|
21
|
-
end
|
18
|
+
sql << 'BINARY' if t.engine.connection.adapter_name =~ /^mysql/i
|
19
|
+
sql << t[attribute].eq(value).to_sql
|
22
20
|
else
|
23
|
-
|
21
|
+
escaped_value = value.gsub(/[%_]/, '\\\\\0')
|
22
|
+
sql << "#{t[attribute].matches(escaped_value).to_sql} ESCAPE '\\'"
|
24
23
|
end
|
25
24
|
|
26
|
-
|
27
|
-
relation = Arel::Nodes::SqlLiteral.new("BINARY #{t[attribute].eq(value).to_sql} AND #{t[klass.primary_key].not_eq(params[:id]).to_sql}")
|
28
|
-
else
|
29
|
-
relation = relation.and(t[klass.primary_key].not_eq(params[:id])) if params[:id]
|
30
|
-
end
|
25
|
+
sql << "AND #{t[klass.primary_key].not_eq(params[:id]).to_sql}" if params[:id]
|
31
26
|
|
32
27
|
(params[:scope] || {}).each do |attribute, value|
|
33
|
-
value
|
34
|
-
|
35
|
-
relation = Arel::Nodes::SqlLiteral.new("#{relation} AND #{t[attribute].eq(value).to_sql}")
|
36
|
-
else
|
37
|
-
relation = relation.and(t[attribute].eq(value))
|
38
|
-
end
|
28
|
+
value = type_cast_value(klass, attribute, value)
|
29
|
+
sql << "AND #{t[attribute].eq(value).to_sql}"
|
39
30
|
end
|
40
31
|
|
32
|
+
relation = Arel::Nodes::SqlLiteral.new(sql.join(' '))
|
41
33
|
!klass.where(relation).exists?
|
42
34
|
end
|
43
35
|
|
@@ -19,7 +19,7 @@ module ClientSideValidations
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def process_request(validation, env)
|
22
|
-
if disabled_validators.include?(validation)
|
22
|
+
if disabled_validators.include?(validation.downcase)
|
23
23
|
error_resp
|
24
24
|
else
|
25
25
|
klass_name = validation.camelize
|
@@ -31,7 +31,7 @@ module ClientSideValidations
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def disabled_validators
|
34
|
-
ClientSideValidations::Config.disabled_validators.map
|
34
|
+
ClientSideValidations::Config.disabled_validators.map { |v| v.to_s.downcase }
|
35
35
|
end
|
36
36
|
|
37
37
|
def error_resp
|
@@ -1,6 +1,6 @@
|
|
1
1
|
(function() {
|
2
2
|
var $, validateElement, validateForm, validatorsFor,
|
3
|
-
|
3
|
+
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
4
4
|
|
5
5
|
$ = jQuery;
|
6
6
|
|
@@ -89,14 +89,14 @@
|
|
89
89
|
return element.trigger('element:validate:after.ClientSideValidations').data('valid') !== false;
|
90
90
|
};
|
91
91
|
executeValidators = function(context) {
|
92
|
-
var fn,
|
92
|
+
var fn, i, kind, len, message, ref, valid, validator;
|
93
93
|
valid = true;
|
94
94
|
for (kind in context) {
|
95
95
|
fn = context[kind];
|
96
96
|
if (validators[kind]) {
|
97
|
-
|
98
|
-
for (
|
99
|
-
validator =
|
97
|
+
ref = validators[kind];
|
98
|
+
for (i = 0, len = ref.length; i < len; i++) {
|
99
|
+
validator = ref[i];
|
100
100
|
if (message = fn.call(context, element, validator)) {
|
101
101
|
valid = failElement(message);
|
102
102
|
break;
|
@@ -167,7 +167,7 @@
|
|
167
167
|
|
168
168
|
window.ClientSideValidations.enablers = {
|
169
169
|
form: function(form) {
|
170
|
-
var $form, binding, event,
|
170
|
+
var $form, binding, event, ref;
|
171
171
|
$form = $(form);
|
172
172
|
form.ClientSideValidations = {
|
173
173
|
settings: window.ClientSideValidations.forms[$form.attr('id')],
|
@@ -178,7 +178,7 @@
|
|
178
178
|
return ClientSideValidations.formBuilders[form.ClientSideValidations.settings.type].remove(element, form.ClientSideValidations.settings);
|
179
179
|
}
|
180
180
|
};
|
181
|
-
|
181
|
+
ref = {
|
182
182
|
'submit.ClientSideValidations': function(eventData) {
|
183
183
|
if (!$form.isValid(form.ClientSideValidations.settings.validators)) {
|
184
184
|
eventData.preventDefault();
|
@@ -203,8 +203,8 @@
|
|
203
203
|
return ClientSideValidations.callbacks.form.pass($form, eventData);
|
204
204
|
}
|
205
205
|
};
|
206
|
-
for (event in
|
207
|
-
binding =
|
206
|
+
for (event in ref) {
|
207
|
+
binding = ref[event];
|
208
208
|
$form.on(event, binding);
|
209
209
|
}
|
210
210
|
return $form.find(ClientSideValidations.selectors.inputs).each(function() {
|
@@ -212,11 +212,11 @@
|
|
212
212
|
});
|
213
213
|
},
|
214
214
|
input: function(input) {
|
215
|
-
var $form, $input, binding, event, form,
|
215
|
+
var $form, $input, binding, event, form, ref;
|
216
216
|
$input = $(input);
|
217
217
|
form = input.form;
|
218
218
|
$form = $(form);
|
219
|
-
|
219
|
+
ref = {
|
220
220
|
'focusout.ClientSideValidations': function() {
|
221
221
|
return $(this).isValid(form.ClientSideValidations.settings.validators);
|
222
222
|
},
|
@@ -244,8 +244,8 @@
|
|
244
244
|
}, eventData);
|
245
245
|
}
|
246
246
|
};
|
247
|
-
for (event in
|
248
|
-
binding =
|
247
|
+
for (event in ref) {
|
248
|
+
binding = ref[event];
|
249
249
|
$input.filter(':not(:radio):not([id$=_confirmation])').each(function() {
|
250
250
|
return $(this).attr('data-validate', true);
|
251
251
|
}).on(event, binding);
|
@@ -255,11 +255,11 @@
|
|
255
255
|
return true;
|
256
256
|
});
|
257
257
|
return $input.filter('[id$=_confirmation]').each(function() {
|
258
|
-
var confirmationElement, element,
|
258
|
+
var confirmationElement, element, ref1, results;
|
259
259
|
confirmationElement = $(this);
|
260
260
|
element = $form.find("#" + (this.id.match(/(.+)_confirmation/)[1]) + ":input");
|
261
261
|
if (element[0]) {
|
262
|
-
|
262
|
+
ref1 = {
|
263
263
|
'focusout.ClientSideValidations': function() {
|
264
264
|
return element.data('changed', true).isValid(form.ClientSideValidations.settings.validators);
|
265
265
|
},
|
@@ -267,12 +267,12 @@
|
|
267
267
|
return element.data('changed', true).isValid(form.ClientSideValidations.settings.validators);
|
268
268
|
}
|
269
269
|
};
|
270
|
-
|
271
|
-
for (event in
|
272
|
-
binding =
|
273
|
-
|
270
|
+
results = [];
|
271
|
+
for (event in ref1) {
|
272
|
+
binding = ref1[event];
|
273
|
+
results.push($("#" + (confirmationElement.attr('id'))).on(event, binding));
|
274
274
|
}
|
275
|
-
return
|
275
|
+
return results;
|
276
276
|
}
|
277
277
|
});
|
278
278
|
}
|
@@ -289,7 +289,7 @@
|
|
289
289
|
}
|
290
290
|
},
|
291
291
|
acceptance: function(element, options) {
|
292
|
-
var
|
292
|
+
var ref;
|
293
293
|
switch (element.attr('type')) {
|
294
294
|
case 'checkbox':
|
295
295
|
if (!element.prop('checked')) {
|
@@ -297,7 +297,7 @@
|
|
297
297
|
}
|
298
298
|
break;
|
299
299
|
case 'text':
|
300
|
-
if (element.val() !== (((
|
300
|
+
if (element.val() !== (((ref = options.accept) != null ? ref.toString() : void 0) || '1')) {
|
301
301
|
return options.message;
|
302
302
|
}
|
303
303
|
}
|
@@ -395,7 +395,7 @@
|
|
395
395
|
}
|
396
396
|
},
|
397
397
|
exclusion: function(element, options) {
|
398
|
-
var lower, message, option,
|
398
|
+
var lower, message, option, ref, upper;
|
399
399
|
message = this.presence(element, options);
|
400
400
|
if (message) {
|
401
401
|
if (options.allow_blank === true) {
|
@@ -404,16 +404,16 @@
|
|
404
404
|
return message;
|
405
405
|
}
|
406
406
|
if (options["in"]) {
|
407
|
-
if (
|
408
|
-
var
|
409
|
-
|
410
|
-
|
411
|
-
for (
|
412
|
-
option =
|
413
|
-
|
407
|
+
if (ref = element.val(), indexOf.call((function() {
|
408
|
+
var i, len, ref1, results;
|
409
|
+
ref1 = options["in"];
|
410
|
+
results = [];
|
411
|
+
for (i = 0, len = ref1.length; i < len; i++) {
|
412
|
+
option = ref1[i];
|
413
|
+
results.push(option.toString());
|
414
414
|
}
|
415
|
-
return
|
416
|
-
})(),
|
415
|
+
return results;
|
416
|
+
})(), ref) >= 0) {
|
417
417
|
return options.message;
|
418
418
|
}
|
419
419
|
}
|
@@ -426,7 +426,7 @@
|
|
426
426
|
}
|
427
427
|
},
|
428
428
|
inclusion: function(element, options) {
|
429
|
-
var lower, message, option,
|
429
|
+
var lower, message, option, ref, upper;
|
430
430
|
message = this.presence(element, options);
|
431
431
|
if (message) {
|
432
432
|
if (options.allow_blank === true) {
|
@@ -435,16 +435,16 @@
|
|
435
435
|
return message;
|
436
436
|
}
|
437
437
|
if (options["in"]) {
|
438
|
-
if (
|
439
|
-
var
|
440
|
-
|
441
|
-
|
442
|
-
for (
|
443
|
-
option =
|
444
|
-
|
438
|
+
if (ref = element.val(), indexOf.call((function() {
|
439
|
+
var i, len, ref1, results;
|
440
|
+
ref1 = options["in"];
|
441
|
+
results = [];
|
442
|
+
for (i = 0, len = ref1.length; i < len; i++) {
|
443
|
+
option = ref1[i];
|
444
|
+
results.push(option.toString());
|
445
445
|
}
|
446
|
-
return
|
447
|
-
})(),
|
446
|
+
return results;
|
447
|
+
})(), ref) >= 0) {
|
448
448
|
return;
|
449
449
|
}
|
450
450
|
return options.message;
|
@@ -495,7 +495,7 @@
|
|
495
495
|
},
|
496
496
|
remote: {
|
497
497
|
uniqueness: function(element, options) {
|
498
|
-
var data, key, message, name, scope_value, scoped_element, scoped_name
|
498
|
+
var data, key, message, name, ref, scope_value, scoped_element, scoped_name;
|
499
499
|
message = ClientSideValidations.validators.local.presence(element, options);
|
500
500
|
if (message) {
|
501
501
|
if (options.allow_blank === true) {
|
@@ -510,9 +510,9 @@
|
|
510
510
|
}
|
511
511
|
if (options.scope) {
|
512
512
|
data.scope = {};
|
513
|
-
|
514
|
-
for (key in
|
515
|
-
scope_value =
|
513
|
+
ref = options.scope;
|
514
|
+
for (key in ref) {
|
515
|
+
scope_value = ref[key];
|
516
516
|
scoped_name = element.attr('name').replace(/\[\w+\]$/, "[" + key + "]");
|
517
517
|
scoped_element = jQuery("[name='" + scoped_name + "']");
|
518
518
|
jQuery("[name='" + scoped_name + "']:checkbox").each(function() {
|
@@ -562,21 +562,21 @@
|
|
562
562
|
};
|
563
563
|
|
564
564
|
window.ClientSideValidations.disableValidators = function() {
|
565
|
-
var func,
|
565
|
+
var func, ref, results, validator;
|
566
566
|
if (window.ClientSideValidations.disabled_validators === void 0) {
|
567
567
|
return;
|
568
568
|
}
|
569
|
-
|
570
|
-
|
571
|
-
for (validator in
|
572
|
-
func =
|
573
|
-
if (
|
574
|
-
|
569
|
+
ref = window.ClientSideValidations.validators.remote;
|
570
|
+
results = [];
|
571
|
+
for (validator in ref) {
|
572
|
+
func = ref[validator];
|
573
|
+
if (indexOf.call(window.ClientSideValidations.disabled_validators, validator) >= 0) {
|
574
|
+
results.push(delete window.ClientSideValidations.validators.remote[validator]);
|
575
575
|
} else {
|
576
|
-
|
576
|
+
results.push(void 0);
|
577
577
|
}
|
578
578
|
}
|
579
|
-
return
|
579
|
+
return results;
|
580
580
|
};
|
581
581
|
|
582
582
|
window.ClientSideValidations.formBuilders = {
|
metadata
CHANGED
@@ -1,153 +1,153 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: client_side_validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Cardarella
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.2.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sqlite3
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: mocha
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: m
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: sinatra
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '1.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: shotgun
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: thin
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: json
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: coffee-script
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: jquery-rails
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
description: Client Side Validations
|
@@ -197,17 +197,17 @@ require_paths:
|
|
197
197
|
- lib
|
198
198
|
required_ruby_version: !ruby/object:Gem::Requirement
|
199
199
|
requirements:
|
200
|
-
- -
|
200
|
+
- - ">="
|
201
201
|
- !ruby/object:Gem::Version
|
202
202
|
version: '0'
|
203
203
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
204
|
requirements:
|
205
|
-
- -
|
205
|
+
- - ">="
|
206
206
|
- !ruby/object:Gem::Version
|
207
207
|
version: '0'
|
208
208
|
requirements: []
|
209
209
|
rubyforge_project:
|
210
|
-
rubygems_version: 2.
|
210
|
+
rubygems_version: 2.4.4
|
211
211
|
signing_key:
|
212
212
|
specification_version: 4
|
213
213
|
summary: Client Side Validations
|