client_side_validations 4.2.11 → 4.2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/lib/client_side_validations/action_view/form_builder.rb +5 -3
- data/lib/client_side_validations/active_model.rb +2 -3
- data/lib/client_side_validations/active_model/conditionals.rb +2 -2
- data/lib/client_side_validations/active_record.rb +5 -6
- data/lib/client_side_validations/version.rb +1 -1
- data/vendor/assets/javascripts/rails.validations.js +7 -7
- metadata +6 -7
- data/HISTORY.md +0 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d645b444078a494c8ee5cc8bfd309dbb0333e29
|
4
|
+
data.tar.gz: 9c9d3a9eb0a97533b8e1ee7c9330748769b45526
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 723c05eda13d578f4da7970b096459709da53b08653e08d5cead6ac01c9170cc221465fe0cd63bd75b85e721a44928952477df7cf1762a50747277b13ca77bea
|
7
|
+
data.tar.gz: 2987e1b5145e88236dac5de8d6540f586177dc00840c302bb796a76b4ba7d22333858461c99cb600927ca1f1e42a06bba2720aaf05be3cddc0f99b468b48741a
|
data/README.md
CHANGED
@@ -145,6 +145,23 @@ In the above case only the `presence` validator will be passed to the client.
|
|
145
145
|
|
146
146
|
This is also the case with [other supported conditional validations](http://guides.rubyonrails.org/v4.2.0/active_record_validations.html#conditional-validation) (such as Procs, Arrays or Strings).
|
147
147
|
|
148
|
+
**NOTE:** when `:if` conditional includes a symbol or a string with
|
149
|
+
`changed?` in it, validator will forced automatically.
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
class Person < ActiveRecord::Base
|
153
|
+
validates :name, presence: true, if: :name_changed?
|
154
|
+
end
|
155
|
+
```
|
156
|
+
|
157
|
+
The presence of name in the example above will be validated
|
158
|
+
without explicit forcing.
|
159
|
+
|
160
|
+
This is done because it is always assumed the value will change on the
|
161
|
+
form.
|
162
|
+
|
163
|
+
Conditionals defined with `:unless` key do not have this optimization.
|
164
|
+
|
148
165
|
### Turning off validators ###
|
149
166
|
|
150
167
|
If you wish to skip validations on a given attribute force it to `false`:
|
@@ -108,11 +108,13 @@ module ClientSideValidations
|
|
108
108
|
def build_validation_options(method, options = {})
|
109
109
|
return unless @options[:validate]
|
110
110
|
|
111
|
-
index
|
112
|
-
name = options[:name] || "#{@object_name}#{index}[#{method}]"
|
111
|
+
index = @default_options[:index].present? ? "[#{@default_options[:index]}]" : ''
|
113
112
|
child_index = @options[:child_index] ? "(\\d+|#{Regexp.escape(@options[:child_index].to_s)})" : '\\d+'
|
113
|
+
|
114
|
+
name = options[:name] || "#{@object_name}#{index}[#{method}]"
|
114
115
|
name = name.to_s.gsub(/_attributes\]\[#{child_index}\]/, '_attributes][]')
|
115
|
-
name
|
116
|
+
name << '[]' if options[:multiple]
|
117
|
+
|
116
118
|
@options[:validators][@object][method] = { name: name, options: options[:validate] }
|
117
119
|
end
|
118
120
|
end
|
@@ -145,8 +145,7 @@ end
|
|
145
145
|
ActiveModel::Validator.send(:include, ClientSideValidations::ActiveModel::Validator)
|
146
146
|
ActiveModel::Validations.send(:include, ClientSideValidations::ActiveModel::Validations)
|
147
147
|
|
148
|
-
%w(
|
149
|
-
require "client_side_validations/active_model/#{validator}"
|
150
|
-
validator.capitalize!
|
148
|
+
%w(Absence Acceptance Exclusion Format Inclusion Length Numericality Presence).each do |validator|
|
149
|
+
require "client_side_validations/active_model/#{validator.downcase}"
|
151
150
|
ActiveModel::Validations.const_get("#{validator}Validator").send :include, ClientSideValidations::ActiveModel.const_get(validator)
|
152
151
|
end
|
@@ -26,9 +26,9 @@ module ClientSideValidations
|
|
26
26
|
raise ArgumentError, 'Missing argument'
|
27
27
|
end
|
28
28
|
when String
|
29
|
-
# rubocop:disable
|
29
|
+
# rubocop:disable Security/Eval'
|
30
30
|
l = eval "lambda { |value| #{conditional} }"
|
31
|
-
# rubocop:enable
|
31
|
+
# rubocop:enable Security/Eval'
|
32
32
|
instance_exec(nil, &l)
|
33
33
|
when Symbol
|
34
34
|
send conditional
|
@@ -2,11 +2,10 @@ require 'client_side_validations/active_model'
|
|
2
2
|
require 'client_side_validations/middleware'
|
3
3
|
require 'client_side_validations/active_record/middleware'
|
4
4
|
|
5
|
-
%w(uniqueness).each do |validator|
|
6
|
-
require "client_side_validations/active_record/#{validator}"
|
7
|
-
validator.capitalize!
|
8
|
-
ActiveRecord::Validations.const_get("#{validator}Validator").send :include, ClientSideValidations::ActiveRecord.const_get(validator)
|
9
|
-
end
|
10
|
-
|
11
5
|
ActiveRecord::Base.send(:include, ClientSideValidations::ActiveModel::Validations)
|
12
6
|
ClientSideValidations::Middleware::Uniqueness.register_orm(ClientSideValidations::ActiveRecord::Middleware)
|
7
|
+
|
8
|
+
%w(Uniqueness).each do |validator|
|
9
|
+
require "client_side_validations/active_record/#{validator.downcase}"
|
10
|
+
ActiveRecord::Validations.const_get("#{validator}Validator").send :include, ClientSideValidations::ActiveRecord.const_get(validator)
|
11
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
/*!
|
3
|
-
* Client Side Validations - v4.2.
|
4
|
-
* Copyright (c)
|
3
|
+
* Client Side Validations - v4.2.12 (https://github.com/DavyJonesLocker/client_side_validations)
|
4
|
+
* Copyright (c) 2017 Geremia Taglialatela, Brian Cardarella
|
5
5
|
* Licensed under MIT (http://opensource.org/licenses/mit-license.php)
|
6
6
|
*/
|
7
7
|
|
@@ -56,7 +56,7 @@
|
|
56
56
|
for (validator_name in validators) {
|
57
57
|
validator = validators[validator_name];
|
58
58
|
if (validator_name.match("\\[" + captures[1] + "\\].*\\[\\]\\[" + captures[2] + "\\]$")) {
|
59
|
-
name = name.replace(/\[[\da-z_]+\]\[(\w+)\]$/g,
|
59
|
+
name = name.replace(/\[[\da-z_]+\]\[(\w+)\]$/g, '[][$1]');
|
60
60
|
}
|
61
61
|
}
|
62
62
|
}
|
@@ -118,7 +118,7 @@
|
|
118
118
|
};
|
119
119
|
if (element.attr('name').search(/\[([^\]]*?)\]$/) >= 0) {
|
120
120
|
destroyInputName = element.attr('name').replace(/\[([^\]]*?)\]$/, '[_destroy]');
|
121
|
-
if ($("input[name='" + destroyInputName + "']").val() ===
|
121
|
+
if ($("input[name='" + destroyInputName + "']").val() === '1') {
|
122
122
|
passElement();
|
123
123
|
return afterValidate();
|
124
124
|
}
|
@@ -342,7 +342,7 @@
|
|
342
342
|
}
|
343
343
|
return options.messages.numericality;
|
344
344
|
}
|
345
|
-
val = val.replace(new RegExp("\\" + ClientSideValidations.number_format.delimiter, 'g'),
|
345
|
+
val = val.replace(new RegExp("\\" + ClientSideValidations.number_format.delimiter, 'g'), '').replace(new RegExp("\\" + ClientSideValidations.number_format.separator, 'g'), '.');
|
346
346
|
if (options.only_integer && !/^[+-]?\d+$/.test(val)) {
|
347
347
|
return options.messages.only_integer;
|
348
348
|
}
|
@@ -484,7 +484,7 @@
|
|
484
484
|
if (name_prefix && name_suffix) {
|
485
485
|
form = element.closest('form');
|
486
486
|
valid = true;
|
487
|
-
form.find(
|
487
|
+
form.find(":input[name^=\"" + name_prefix + "\"][name$=\"" + name_suffix + "\"]").each(function() {
|
488
488
|
if ($(this).attr('name') !== name) {
|
489
489
|
if ($(this).val() === value) {
|
490
490
|
valid = false;
|
@@ -548,7 +548,7 @@
|
|
548
548
|
name = element.attr('name');
|
549
549
|
}
|
550
550
|
if (options['class']) {
|
551
|
-
name = options['class'] +
|
551
|
+
name = options['class'] + "[" + (name.split('[')[1]);
|
552
552
|
}
|
553
553
|
data[name] = element.val();
|
554
554
|
if ($.ajax({
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: client_side_validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geremia Taglialatela
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-01-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -105,14 +105,14 @@ dependencies:
|
|
105
105
|
requirements:
|
106
106
|
- - "~>"
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version: 0.8.
|
108
|
+
version: 0.8.18
|
109
109
|
type: :development
|
110
110
|
prerelease: false
|
111
111
|
version_requirements: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
113
|
- - "~>"
|
114
114
|
- !ruby/object:Gem::Version
|
115
|
-
version: 0.8.
|
115
|
+
version: 0.8.18
|
116
116
|
- !ruby/object:Gem::Dependency
|
117
117
|
name: m
|
118
118
|
requirement: !ruby/object:Gem::Requirement
|
@@ -181,14 +181,14 @@ dependencies:
|
|
181
181
|
requirements:
|
182
182
|
- - "~>"
|
183
183
|
- !ruby/object:Gem::Version
|
184
|
-
version: 0.
|
184
|
+
version: 0.47.1
|
185
185
|
type: :development
|
186
186
|
prerelease: false
|
187
187
|
version_requirements: !ruby/object:Gem::Requirement
|
188
188
|
requirements:
|
189
189
|
- - "~>"
|
190
190
|
- !ruby/object:Gem::Version
|
191
|
-
version: 0.
|
191
|
+
version: 0.47.1
|
192
192
|
- !ruby/object:Gem::Dependency
|
193
193
|
name: simplecov
|
194
194
|
requirement: !ruby/object:Gem::Requirement
|
@@ -281,7 +281,6 @@ executables: []
|
|
281
281
|
extensions: []
|
282
282
|
extra_rdoc_files: []
|
283
283
|
files:
|
284
|
-
- HISTORY.md
|
285
284
|
- README.md
|
286
285
|
- lib/client_side_validations.rb
|
287
286
|
- lib/client_side_validations/action_view.rb
|
data/HISTORY.md
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
# ClientSideValidation History
|
2
|
-
|
3
|
-
## Version 4.2
|
4
|
-
|
5
|
-
* [v4.2.10](https://github.com/DavyJonesLocker/client_side_validations/compare/v4.2.9...v4.2.10)
|
6
|
-
* [v4.2.9](https://github.com/DavyJonesLocker/client_side_validations/compare/v4.2.8...v4.2.9)
|
7
|
-
* [v4.2.8](https://github.com/DavyJonesLocker/client_side_validations/compare/v4.2.7...v4.2.8)
|
8
|
-
* [v4.2.7](https://github.com/DavyJonesLocker/client_side_validations/compare/v4.2.6...v4.2.7)
|
9
|
-
* [v4.2.6](https://github.com/DavyJonesLocker/client_side_validations/compare/v4.2.5...v4.2.6)
|
10
|
-
* [v4.2.5](https://github.com/DavyJonesLocker/client_side_validations/compare/v4.2.4...v4.2.5)
|
11
|
-
* [v4.2.4](https://github.com/DavyJonesLocker/client_side_validations/compare/v4.2.3...v4.2.4)
|
12
|
-
* [v4.2.3](https://github.com/DavyJonesLocker/client_side_validations/compare/v4.2.2...v4.2.3)
|
13
|
-
* [v4.2.2](https://github.com/DavyJonesLocker/client_side_validations/compare/v4.2.1...v4.2.2)
|
14
|
-
* [v4.2.1](https://github.com/DavyJonesLocker/client_side_validations/compare/v4.2.0...v4.2.1)
|
15
|
-
* [v4.2.0](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.2.6...v4.2.0)
|
16
|
-
|
17
|
-
## Version 3.2
|
18
|
-
|
19
|
-
* [v3.2.6](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.2.5...v3.2.6)
|
20
|
-
* [v3.2.5](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.2.4...v3.2.5)
|
21
|
-
* [v3.2.4](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.2.3...v3.2.4)
|
22
|
-
* [v3.2.3](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.2.2...v3.2.3)
|
23
|
-
* [v3.2.2](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.2.1...v3.2.2)
|
24
|
-
* [v3.2.1](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.2.0...v3.2.1)
|
25
|
-
* [v3.2.0](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.1.5...v3.2.0)
|
26
|
-
|
27
|
-
## Version 3.1
|
28
|
-
|
29
|
-
* [v3.1.5](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.1.4...v3.1.5)
|
30
|
-
* [v3.1.4](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.1.3...v3.1.4)
|
31
|
-
* [v3.1.3](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.1.2...v3.1.3)
|
32
|
-
* [v3.1.2](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.1.1...v3.1.2)
|
33
|
-
* [v3.1.1](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.1.0...v3.1.1)
|
34
|
-
* [v3.1.0](https://github.com/DavyJonesLocker/client_side_validations/compare/badf88aa6a09012900e9275bb01c80f4d19482ce...v3.1.0)
|
35
|
-
|
36
|
-
## Version 3.0
|
37
|
-
|
38
|
-
* [v3.0.13](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.0.12...v3.0.13)
|
39
|
-
* [v3.0.12](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.0.11...v3.0.12)
|
40
|
-
* [v3.0.11](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.0.10...v3.0.11)
|
41
|
-
* [v3.0.10](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.0.9...v3.0.10)
|
42
|
-
* [v3.0.9](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.0.8...v3.0.9)
|
43
|
-
* [v3.0.8](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.0.7...v3.0.8)
|
44
|
-
* [v3.0.7](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.0.6...v3.0.7)
|
45
|
-
* [v3.0.6](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.0.5...v3.0.6)
|
46
|
-
* [v3.0.5](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.0.4...v3.0.5)
|
47
|
-
* [v3.0.4](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.0.3...v3.0.4)
|
48
|
-
* [v3.0.3](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.0.2...v3.0.3)
|
49
|
-
* [v3.0.2](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.0.1...v3.0.2)
|
50
|
-
* [v3.0.1](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.0.0...v3.0.1)
|
51
|
-
* [v3.0.0](https://github.com/DavyJonesLocker/client_side_validations/compare/4c6262702e513f1c4c063d36ccc88c0f3071199a...v3.0.0)
|
52
|
-
|
53
|
-
## Prior to Version 3.0
|
54
|
-
|
55
|
-
This gem was a re-write of the original [ClientSideValidationsgem](https://github.com/dnclabs/client_side_validations).
|
56
|
-
Versions were not tagged.
|