client_side_validations 18.0.0 → 18.1.0

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
  SHA256:
3
- metadata.gz: 8dc15936a8857d5311c69d449ec11b43d4e3aa5f1d9aead78c65e9066f71cbf4
4
- data.tar.gz: 36cca6a91972fdd818bda21b9ea3b9cb85f196c88e197872389df21ca090701d
3
+ metadata.gz: 0e48473024c86d20fe68330cfeb13e2fdc29e4c0a8c619fb51e980d03ec8aae7
4
+ data.tar.gz: 67c48790216518f72154e35c22914f4464edea104eaf1538daa772eb5b71ccfc
5
5
  SHA512:
6
- metadata.gz: 1b4d6d4eb7b3e3e79bd2cfa4823a7de7802a2bbd0bbba6f0a8e65862e03fff70f7cdb75fec64e22d7b689b1f9ea2c3edf952cc95c6552c6274f70da126f988eb
7
- data.tar.gz: 9efe40881ffc2cbb86b1d02de44318807da27d58859033e0d6a4231c4f3c33c89d8dace2f99f0541b68380279cbff658003895e5460ebdf526b72ec721cbf044
6
+ metadata.gz: 865cfdfb27838f0fc6718a4fa39ce731c05838a03e4e92d700b0f14a1cf555f782a0db1aab98d38eac8fa2d4cb807a109a551b11b454c563a6f3b60f322b19ca
7
+ data.tar.gz: d649a17bf8585839bb0b2ccff97b4f63ee0ddeed9532ca5c97158db427ff8291aea086bc38f0fa440f8f8ac87c6621356b15688689c0b58bb86fc5684ee7190a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 18.1.0 / 2021-06-13
4
+
5
+ * [FEATURE] Add support to `fields` method ([#828](https://github.com/DavyJonesLocker/client_side_validations/pull/828))
6
+ * [ENHANCEMENT] Test against jQuery 3.6.0 by default
7
+ * [ENHANCEMENT] Test against latest Ruby versions
8
+ * [ENHANCEMENT] Update QUnit to 2.15.0
9
+
3
10
  ## 18.0.0 / 2021-02-13
4
11
 
5
12
  * [FEATURE] Add Rails 7.0.pre compatibility
@@ -5,7 +5,7 @@ module ClientSideValidations
5
5
  module Helpers
6
6
  module FormBuilder
7
7
  def self.prepended(base)
8
- (base.field_helpers - %i[label check_box radio_button fields_for hidden_field file_field]).each do |selector|
8
+ (base.field_helpers - %i[label check_box radio_button fields_for fields hidden_field file_field]).each do |selector|
9
9
  base.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
10
10
  # Cannot call super here, rewrite all
11
11
  def #{selector}(method, options = {}) # def text_field(method, options = {})
@@ -72,6 +72,11 @@ module ClientSideValidations
72
72
  super(record_name, record_object, fields_options, &block)
73
73
  end
74
74
 
75
+ def fields(scope = nil, model: nil, **options, &block)
76
+ options[:validate] ||= @options[:validate] if @options[:validate] && !options.key?(:validate)
77
+ super(scope, model: model, **options, &block)
78
+ end
79
+
75
80
  def file_field(method, options = {})
76
81
  build_validation_options(method, options)
77
82
  options.delete(:validate)
@@ -6,7 +6,14 @@ module ClientSideValidations
6
6
  @@option_map = {}
7
7
 
8
8
  def self.included(base)
9
- @@option_map.merge!(base::CHECKS.keys.inject({}) { |acc, elem| acc.merge!(elem => elem) })
9
+ checks =
10
+ if base.const_defined?('RESERVED_OPTIONS')
11
+ base::RESERVED_OPTIONS - [:only_integer]
12
+ else
13
+ base::CHECKS.keys
14
+ end
15
+
16
+ @@option_map.merge!(checks.inject({}) { |acc, elem| acc.merge!(elem => elem) })
10
17
  super
11
18
  end
12
19
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClientSideValidations
4
- VERSION = '18.0.0'
4
+ VERSION = '18.1.0'
5
5
  end
@@ -344,7 +344,7 @@
344
344
  }
345
345
  };
346
346
 
347
- var VALIDATIONS = {
347
+ var VALIDATIONS$1 = {
348
348
  even: function even(a) {
349
349
  return parseInt(a, 10) % 2 === 0;
350
350
  },
@@ -395,9 +395,9 @@
395
395
  };
396
396
 
397
397
  var runFunctionValidations = function runFunctionValidations(formattedValue, $form, options) {
398
- for (var validation in VALIDATIONS) {
398
+ for (var validation in VALIDATIONS$1) {
399
399
  var validationOption = options[validation];
400
- var validationFunction = VALIDATIONS[validation]; // Must check for null because this could be 0
400
+ var validationFunction = VALIDATIONS$1[validation]; // Must check for null because this could be 0
401
401
 
402
402
  if (validationOption == null) {
403
403
  continue;
@@ -409,7 +409,7 @@
409
409
  }
410
410
  };
411
411
 
412
- var runValidations = function runValidations(formattedValue, $form, options) {
412
+ var runValidations$1 = function runValidations(formattedValue, $form, options) {
413
413
  if (options.only_integer && !ClientSideValidations.patterns.numericality.only_integer.test(formattedValue)) {
414
414
  return options.messages.only_integer;
415
415
  }
@@ -431,10 +431,10 @@
431
431
  var $form = $__default['default'](element[0].form);
432
432
  var numberFormat = $form[0].ClientSideValidations.settings.number_format;
433
433
  var formattedValue = $__default['default'].trim(value).replace(new RegExp('\\' + numberFormat.separator, 'g'), '.');
434
- return runValidations(formattedValue, $form, options);
434
+ return runValidations$1(formattedValue, $form, options);
435
435
  };
436
436
 
437
- var VALIDATIONS$1 = {
437
+ var VALIDATIONS = {
438
438
  is: function is(a, b) {
439
439
  return a === parseInt(b, 10);
440
440
  },
@@ -446,10 +446,10 @@
446
446
  }
447
447
  };
448
448
 
449
- var runValidations$1 = function runValidations(valueLength, options) {
450
- for (var validation in VALIDATIONS$1) {
449
+ var runValidations = function runValidations(valueLength, options) {
450
+ for (var validation in VALIDATIONS) {
451
451
  var validationOption = options[validation];
452
- var validationFunction = VALIDATIONS$1[validation];
452
+ var validationFunction = VALIDATIONS[validation];
453
453
 
454
454
  if (validationOption && !validationFunction(valueLength, validationOption)) {
455
455
  return options.messages[validation];
@@ -464,7 +464,7 @@
464
464
  return;
465
465
  }
466
466
 
467
- return runValidations$1(value.length, options);
467
+ return runValidations(value.length, options);
468
468
  };
469
469
 
470
470
  var isInList = function isInList(value, otherValues) {
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: 18.0.0
4
+ version: 18.1.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: 2021-02-13 00:00:00.000000000 Z
12
+ date: 2021-06-13 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: '2.3'
54
+ version: '2.4'
55
55
  type: :development
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: '2.3'
61
+ version: '2.4'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: byebug
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -77,16 +77,22 @@ dependencies:
77
77
  name: coveralls_reborn
78
78
  requirement: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0.21'
83
+ - - "<"
81
84
  - !ruby/object:Gem::Version
82
- version: 0.20.0
85
+ version: '0.23'
83
86
  type: :development
84
87
  prerelease: false
85
88
  version_requirements: !ruby/object:Gem::Requirement
86
89
  requirements:
87
- - - "~>"
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0.21'
93
+ - - "<"
88
94
  - !ruby/object:Gem::Version
89
- version: 0.20.0
95
+ version: '0.23'
90
96
  - !ruby/object:Gem::Dependency
91
97
  name: m
92
98
  requirement: !ruby/object:Gem::Requirement
@@ -143,76 +149,6 @@ dependencies:
143
149
  - - "~>"
144
150
  - !ruby/object:Gem::Version
145
151
  version: '13.0'
146
- - !ruby/object:Gem::Dependency
147
- name: rubocop
148
- requirement: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '1.9'
153
- type: :development
154
- prerelease: false
155
- version_requirements: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: '1.9'
160
- - !ruby/object:Gem::Dependency
161
- name: rubocop-minitest
162
- requirement: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: 0.10.3
167
- type: :development
168
- prerelease: false
169
- version_requirements: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
172
- - !ruby/object:Gem::Version
173
- version: 0.10.3
174
- - !ruby/object:Gem::Dependency
175
- name: rubocop-performance
176
- requirement: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: '1.9'
181
- type: :development
182
- prerelease: false
183
- version_requirements: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - "~>"
186
- - !ruby/object:Gem::Version
187
- version: '1.9'
188
- - !ruby/object:Gem::Dependency
189
- name: rubocop-rails
190
- requirement: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - "~>"
193
- - !ruby/object:Gem::Version
194
- version: '2.9'
195
- type: :development
196
- prerelease: false
197
- version_requirements: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - "~>"
200
- - !ruby/object:Gem::Version
201
- version: '2.9'
202
- - !ruby/object:Gem::Dependency
203
- name: rubocop-rake
204
- requirement: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - "~>"
207
- - !ruby/object:Gem::Version
208
- version: 0.5.1
209
- type: :development
210
- prerelease: false
211
- version_requirements: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - "~>"
214
- - !ruby/object:Gem::Version
215
- version: 0.5.1
216
152
  - !ruby/object:Gem::Dependency
217
153
  name: simplecov
218
154
  requirement: !ruby/object:Gem::Requirement
@@ -353,7 +289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
353
289
  - !ruby/object:Gem::Version
354
290
  version: '0'
355
291
  requirements: []
356
- rubygems_version: 3.1.4
292
+ rubygems_version: 3.1.6
357
293
  signing_key:
358
294
  specification_version: 4
359
295
  summary: Client Side Validations