client_side_validations 3.2.0.rc.2 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/client_side_validations/action_view/form_builder.rb +3 -2
- data/lib/client_side_validations/active_model.rb +1 -6
- data/lib/client_side_validations/config.rb +3 -2
- data/lib/client_side_validations/middleware.rb +7 -4
- data/lib/client_side_validations/version.rb +1 -1
- data/lib/generators/templates/client_side_validations/initializer.rb +1 -1
- data/vendor/assets/javascripts/rails.validations.js +2 -2
- metadata +9 -6
@@ -35,8 +35,9 @@ module ClientSideValidations::ActionView::Helpers
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def validate(*attrs)
|
38
|
-
attrs.
|
39
|
-
|
38
|
+
options = attrs.pop if attrs.last.is_a?(Hash)
|
39
|
+
(attrs.present? ? attrs : @object._validators.keys).each do |attr|
|
40
|
+
build_validation_options(attr, :validate => options)
|
40
41
|
end
|
41
42
|
nil
|
42
43
|
end
|
@@ -68,7 +68,6 @@ module ClientSideValidations::ActiveModel
|
|
68
68
|
# Yeah yeah, #new_record? is not part of ActiveModel :p
|
69
69
|
result = ((self.respond_to?(:new_record?) && validator.options[:on] == (self.new_record? ? :create : :update)) || validator.options[:on].nil?)
|
70
70
|
result = result && validator.kind != :block
|
71
|
-
result = result && uniqueness_validations_allowed_or_not_applicable?(validator)
|
72
71
|
|
73
72
|
if validator.options[:if] || validator.options[:unless]
|
74
73
|
if result = can_force_validator?(attr, validator, force)
|
@@ -108,7 +107,7 @@ module ClientSideValidations::ActiveModel
|
|
108
107
|
false
|
109
108
|
end
|
110
109
|
else
|
111
|
-
|
110
|
+
::ClientSideValidations::Config.disabled_validators.include?(validator.kind)
|
112
111
|
end
|
113
112
|
end
|
114
113
|
|
@@ -133,10 +132,6 @@ module ClientSideValidations::ActiveModel
|
|
133
132
|
end
|
134
133
|
end
|
135
134
|
end
|
136
|
-
|
137
|
-
def uniqueness_validations_allowed_or_not_applicable?(validator)
|
138
|
-
validator.kind != :uniqueness || !ClientSideValidations::Config.uniqueness_validator_disabled
|
139
|
-
end
|
140
135
|
end
|
141
136
|
end
|
142
137
|
|
@@ -11,11 +11,14 @@ module ClientSideValidations
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def call(env)
|
14
|
-
matches = /^\/validators\/(\w+)$/.match(env['PATH_INFO'])
|
15
|
-
|
16
|
-
|
14
|
+
if matches = /^\/validators\/(\w+)$/.match(env['PATH_INFO'])
|
15
|
+
if ClientSideValidations::Config.disabled_validators.include?(matches[1].to_sym)
|
16
|
+
[500, {'Content-Type' => 'application/json', 'Content-Length' => 0}, ['']]
|
17
|
+
else
|
18
|
+
"::ClientSideValidations::Middleware::#{matches[1].camelize}".constantize.new(env).response
|
19
|
+
end
|
17
20
|
else
|
18
|
-
|
21
|
+
@app.call(env)
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# ClientSideValidations Initializer
|
2
2
|
|
3
3
|
# Uncomment to disable uniqueness validator, possible security issue
|
4
|
-
# ClientSideValidations::Config.
|
4
|
+
# ClientSideValidations::Config.disabled_validators = [:uniqueness]
|
5
5
|
|
6
6
|
# Uncomment the following block if you want each input field to have the validation messages attached.
|
7
7
|
# ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
|
@@ -12,7 +12,7 @@
|
|
12
12
|
this.filter('form[data-validate]').each(function() {
|
13
13
|
return ClientSideValidations.enablers.form(this);
|
14
14
|
});
|
15
|
-
return this.filter(':input').each(function() {
|
15
|
+
return this.filter(':input:not(button)').each(function() {
|
16
16
|
return ClientSideValidations.enablers.input(this);
|
17
17
|
});
|
18
18
|
};
|
@@ -229,7 +229,7 @@
|
|
229
229
|
};
|
230
230
|
for (event in _ref) {
|
231
231
|
binding = _ref[event];
|
232
|
-
$input.filter(':enabled:not(:radio):not([id$=_confirmation]):visible').each(function() {
|
232
|
+
$input.filter(':enabled:not(:radio):not([id$=_confirmation]):visible:not(button)[name]').each(function() {
|
233
233
|
return $(this).attr('data-validate', true);
|
234
234
|
}).on(event, binding);
|
235
235
|
}
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: client_side_validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.0
|
5
|
-
prerelease:
|
4
|
+
version: 3.2.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brian Cardarella
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -223,13 +223,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
223
223
|
version: '0'
|
224
224
|
segments:
|
225
225
|
- 0
|
226
|
-
hash:
|
226
|
+
hash: 4066478814748043567
|
227
227
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
228
|
none: false
|
229
229
|
requirements:
|
230
|
-
- - ! '
|
230
|
+
- - ! '>='
|
231
231
|
- !ruby/object:Gem::Version
|
232
|
-
version:
|
232
|
+
version: '0'
|
233
|
+
segments:
|
234
|
+
- 0
|
235
|
+
hash: 4066478814748043567
|
233
236
|
requirements: []
|
234
237
|
rubyforge_project:
|
235
238
|
rubygems_version: 1.8.23
|