client_side_validations 11.1.3 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/client_side_validations/action_view/form_builder.rb +1 -1
- data/lib/client_side_validations/action_view/form_helper.rb +3 -1
- data/lib/client_side_validations/active_model.rb +2 -0
- data/lib/client_side_validations/active_model/format.rb +2 -0
- data/lib/client_side_validations/active_model/length.rb +1 -2
- data/lib/client_side_validations/active_model/numericality.rb +1 -0
- data/lib/client_side_validations/core_ext/regexp.rb +1 -1
- data/lib/client_side_validations/version.rb +1 -1
- data/lib/generators/client_side_validations/copy_assets_generator.rb +1 -0
- data/vendor/assets/javascripts/rails.validations.js +39 -27
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3363fadd705aaa2465892b932a0c12c0d39b3281cb513db4a995bb1f2f6014e5
|
4
|
+
data.tar.gz: 1e307e3dffee20217b2d2b1860f6d3d2ef51cdd9cefc6a1a35081af51ae47451
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a01830948811607a0bc6edbbb097d33ab9e36926f3fef83f7e1ea6b7a0b70e76a48a8e2bf8e3b5497a35ba8fa7e24fa2f8a6c35c9d966eb353ff1904112d0023
|
7
|
+
data.tar.gz: ef4cf650a6a33552a189436a502aa16ed878b761554c43198117be63a0192d7f31e2c28a5f7f8b3155798eda2b6015196b22f5730e7a390753a0cd6d9896e36e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 12.0.0 / 2018-12-12
|
4
|
+
|
5
|
+
* [FEATURE] Drop the deprecated tokenizer support in length validator
|
6
|
+
* [ENHANCEMENT] Do not use `New Function` ([#733](https://github.com/DavyJonesLocker/client_side_validations/issues/733))
|
7
|
+
* [ENHANCEMENT] Remove 'g' flag from RegExp conversions ([#750](https://github.com/DavyJonesLocker/client_side_validations/issues/750))
|
8
|
+
* [ENHANCEMENT] Update dependencies
|
9
|
+
|
3
10
|
## 11.1.3 / 2018-09-08
|
4
11
|
|
5
12
|
* [ENHANCEMENT] Test against jQuery 3.3.1 by default
|
@@ -24,7 +24,7 @@ module ClientSideValidations
|
|
24
24
|
|
25
25
|
def client_side_form_settings(_options, form_helper)
|
26
26
|
{
|
27
|
-
type:
|
27
|
+
type: self.class.to_s,
|
28
28
|
input_tag: form_helper.class.field_error_proc.call(%(<span id="input_tag" />), Struct.new(:error_message, :tag_id).new([], '')),
|
29
29
|
label_tag: form_helper.class.field_error_proc.call(%(<label id="label_tag" />), Struct.new(:error_message, :tag_id).new([], ''))
|
30
30
|
}
|
@@ -14,6 +14,7 @@ module ClientSideValidations
|
|
14
14
|
# to inject the csv options in a data attribute in a clean way.
|
15
15
|
# So we basically reimplement the whole form_for method
|
16
16
|
raise ArgumentError, 'Missing block' unless block_given?
|
17
|
+
|
17
18
|
html_options = options[:html] ||= {}
|
18
19
|
|
19
20
|
# Moving the switch statement to another method to
|
@@ -58,6 +59,7 @@ module ClientSideValidations
|
|
58
59
|
else
|
59
60
|
object = record.is_a?(Array) ? record.last : record
|
60
61
|
raise ArgumentError, 'First argument in form cannot contain nil or be empty' unless object
|
62
|
+
|
61
63
|
object_name = options[:as] || model_name_from_record_or_class(object).param_key
|
62
64
|
apply_form_for_options!(record, object, options)
|
63
65
|
end
|
@@ -133,7 +135,7 @@ module ClientSideValidations
|
|
133
135
|
csv_options = {
|
134
136
|
html_settings: builder.client_side_form_settings(options, self),
|
135
137
|
number_format: number_format,
|
136
|
-
validators:
|
138
|
+
validators: construct_validators
|
137
139
|
}
|
138
140
|
|
139
141
|
html_options['data-client-side-validations'] = csv_options.to_json
|
@@ -105,6 +105,7 @@ module ClientSideValidations
|
|
105
105
|
|
106
106
|
def validator_turned_off?(attr, validator, force)
|
107
107
|
return true if ::ClientSideValidations::Config.disabled_validators.include?(validator.kind)
|
108
|
+
|
108
109
|
case force
|
109
110
|
when FalseClass
|
110
111
|
true
|
@@ -147,6 +148,7 @@ module ClientSideValidations
|
|
147
148
|
|
148
149
|
if options[:in].respond_to?(:call)
|
149
150
|
return unless force
|
151
|
+
|
150
152
|
options[:in] = options[:in].call(model)
|
151
153
|
end
|
152
154
|
|
@@ -7,10 +7,12 @@ module ClientSideValidations
|
|
7
7
|
options = self.options.dup
|
8
8
|
if options[:with].respond_to?(:call)
|
9
9
|
return unless force
|
10
|
+
|
10
11
|
options[:with] = options[:with].call(model)
|
11
12
|
build_client_side_hash(model, attribute, options)
|
12
13
|
elsif options[:without].respond_to?(:call)
|
13
14
|
return unless force
|
15
|
+
|
14
16
|
options[:without] = options[:without].call(model)
|
15
17
|
build_client_side_hash(model, attribute, options)
|
16
18
|
else
|
@@ -26,8 +26,7 @@ module ClientSideValidations
|
|
26
26
|
|
27
27
|
def options_hash(options)
|
28
28
|
hash = { messages: {} }
|
29
|
-
hash[:
|
30
|
-
hash[:allow_blank] = true if options[:allow_nil] || options[:allow_blank]
|
29
|
+
hash[:allow_blank] = true if options[:allow_nil] || options[:allow_blank]
|
31
30
|
hash
|
32
31
|
end
|
33
32
|
end
|
@@ -5,6 +5,7 @@ module ClientSideValidations
|
|
5
5
|
class CopyAssetsGenerator < Rails::Generators::Base
|
6
6
|
def copy_javascript_asset
|
7
7
|
return unless self.class == CopyAssetsGenerator || !asset_pipeline_enabled?
|
8
|
+
|
8
9
|
assets.each do |asset|
|
9
10
|
source_paths << asset[:path]
|
10
11
|
copy_file asset[:file], "#{asset_directory}/#{asset[:file]}"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
/*!
|
3
|
-
* Client Side Validations -
|
3
|
+
* Client Side Validations - v12.0.0 (https://github.com/DavyJonesLocker/client_side_validations)
|
4
4
|
* Copyright (c) 2018 Geremia Taglialatela, Brian Cardarella
|
5
5
|
* Licensed under MIT (http://opensource.org/licenses/mit-license.php)
|
6
6
|
*/
|
@@ -363,7 +363,7 @@
|
|
363
363
|
}
|
364
364
|
},
|
365
365
|
numericality: function(element, options) {
|
366
|
-
var $form,
|
366
|
+
var $form, NUMERICALITY_CHECKS, check, checkValue, check_function, number_format, val;
|
367
367
|
if (options.allow_blank === true && this.presence(element, {
|
368
368
|
message: options.messages.numericality
|
369
369
|
})) {
|
@@ -378,15 +378,25 @@
|
|
378
378
|
if (!ClientSideValidations.patterns.numericality["default"].test(val)) {
|
379
379
|
return options.messages.numericality;
|
380
380
|
}
|
381
|
-
|
382
|
-
greater_than:
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
381
|
+
NUMERICALITY_CHECKS = {
|
382
|
+
greater_than: function(a, b) {
|
383
|
+
return a > b;
|
384
|
+
},
|
385
|
+
greater_than_or_equal_to: function(a, b) {
|
386
|
+
return a >= b;
|
387
|
+
},
|
388
|
+
equal_to: function(a, b) {
|
389
|
+
return a === b;
|
390
|
+
},
|
391
|
+
less_than: function(a, b) {
|
392
|
+
return a < b;
|
393
|
+
},
|
394
|
+
less_than_or_equal_to: function(a, b) {
|
395
|
+
return a <= b;
|
396
|
+
}
|
387
397
|
};
|
388
|
-
for (check in
|
389
|
-
|
398
|
+
for (check in NUMERICALITY_CHECKS) {
|
399
|
+
check_function = NUMERICALITY_CHECKS[check];
|
390
400
|
if (!(options[check] != null)) {
|
391
401
|
continue;
|
392
402
|
}
|
@@ -394,8 +404,7 @@
|
|
394
404
|
if ((checkValue == null) || checkValue === '') {
|
395
405
|
return;
|
396
406
|
}
|
397
|
-
|
398
|
-
if (!fn()) {
|
407
|
+
if (!check_function(parseFloat(val), parseFloat(checkValue))) {
|
399
408
|
return options.messages[check];
|
400
409
|
}
|
401
410
|
}
|
@@ -407,13 +416,18 @@
|
|
407
416
|
}
|
408
417
|
},
|
409
418
|
length: function(element, options) {
|
410
|
-
var
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
419
|
+
var LENGTH_CHECKS, blankOptions, check, check_function, length, message;
|
420
|
+
length = element.val().length;
|
421
|
+
LENGTH_CHECKS = {
|
422
|
+
is: function(a, b) {
|
423
|
+
return a === b;
|
424
|
+
},
|
425
|
+
minimum: function(a, b) {
|
426
|
+
return a >= b;
|
427
|
+
},
|
428
|
+
maximum: function(a, b) {
|
429
|
+
return a <= b;
|
430
|
+
}
|
417
431
|
};
|
418
432
|
blankOptions = {};
|
419
433
|
blankOptions.message = options.is ? options.messages.is : options.minimum ? options.messages.minimum : void 0;
|
@@ -424,14 +438,12 @@
|
|
424
438
|
}
|
425
439
|
return message;
|
426
440
|
}
|
427
|
-
for (check in
|
428
|
-
|
429
|
-
if (
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
if (!fn()) {
|
434
|
-
return options.messages[check];
|
441
|
+
for (check in LENGTH_CHECKS) {
|
442
|
+
check_function = LENGTH_CHECKS[check];
|
443
|
+
if (options[check]) {
|
444
|
+
if (!check_function(length, parseInt(options[check]))) {
|
445
|
+
return options.messages[check];
|
446
|
+
}
|
435
447
|
}
|
436
448
|
}
|
437
449
|
},
|
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
|
+
version: 12.0.0
|
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: 2018-
|
12
|
+
date: 2018-12-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -51,14 +51,14 @@ dependencies:
|
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.1'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
61
|
+
version: '3.1'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: appraisal
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -163,14 +163,14 @@ dependencies:
|
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.
|
166
|
+
version: 0.61.1
|
167
167
|
type: :development
|
168
168
|
prerelease: false
|
169
169
|
version_requirements: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 0.
|
173
|
+
version: 0.61.1
|
174
174
|
- !ruby/object:Gem::Dependency
|
175
175
|
name: simplecov
|
176
176
|
requirement: !ruby/object:Gem::Requirement
|