client_side_validations 9.3.4 → 10.0.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
  SHA1:
3
- metadata.gz: 8bceb161a57c46e4dfe0e6a6885551507ccc7711
4
- data.tar.gz: 27e9454b3c119a965a412b5e0324819b39640215
3
+ metadata.gz: 1c59886758b11f1721e68456f762260ebac95d5e
4
+ data.tar.gz: 1295e066607efc41e1aed2d9b1e7b928a40fbf3b
5
5
  SHA512:
6
- metadata.gz: 297c1c2cded360d5352fff89fb797d180afcbb3ff7b0e2cbeeb3c7e534d9d19a034f2e1150a7511108e6cdabad125715e215de974f0d9685d1aacda260706fa7
7
- data.tar.gz: 9160c9702b3c47d26450d49ce408a5e2e2319e6f2ba617b49d7856c0eaaa7094050f00738450a54dfd48fccee60944a49cee281a89235d2dfafad29bb3e7b704
6
+ metadata.gz: 79707fcac5b515a7c618e17d0a0eef06a0bd3c20e63400574368bc46002231380d715059d73d3e864c3943d4f0cbf09f203baf7c7dd5466bb340047a18b17ae4
7
+ data.tar.gz: 3aa020cec77bcf778ce766f5f1e3f45ff742ac6cb071b9a7610ebde3081af41d77312b51960ebd6300dea94663fff512f0dc1aa58f2bbf08c3a9cd1b67caf56f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 10.0.0 / 2017-10-09
4
+
5
+ * [FEATURE] Refactor client-side numericality validator ([#717](https://github.com/DavyJonesLocker/client_side_validations/issues/717))
6
+ * [ENHANCEMENT] Test against Ruby 2.2.8, 2.3.5, and 2.4.2
7
+ * [ENHANCEMENT] Update js_regex runtime depenency to 2.0
8
+ * [ENHANCEMENT] Update development dependencies
9
+
3
10
  ## 9.3.4 / 2017-07-15
4
11
 
5
12
  * [BUGFIX] Validate will_save_change_to? conditionals
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClientSideValidations
4
- VERSION = '9.3.4'.freeze
4
+ VERSION = '10.0.0'.freeze
5
5
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*!
3
- * Client Side Validations - v9.3.4 (https://github.com/DavyJonesLocker/client_side_validations)
3
+ * Client Side Validations - v10.0.0 (https://github.com/DavyJonesLocker/client_side_validations)
4
4
  * Copyright (c) 2017 Geremia Taglialatela, Brian Cardarella
5
5
  * Licensed under MIT (http://opensource.org/licenses/mit-license.php)
6
6
  */
@@ -309,8 +309,9 @@
309
309
  }
310
310
  },
311
311
  patterns: {
312
- numericality: function(number_format) {
313
- return new RegExp("^(-|\\+)?(?:\\d+|\\d{1,3}(?:\\" + number_format.delimiter + "\\d{3})+)(?:\\" + number_format.separator + "\\d*)?$");
312
+ numericality: {
313
+ "default": new RegExp('^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$'),
314
+ only_integer: new RegExp('^[+-]?\\d+$')
314
315
  }
315
316
  },
316
317
  selectors: {
@@ -366,9 +367,12 @@
366
367
  numericality: function(element, options) {
367
368
  var $form, CHECKS, check, checkValue, fn, number_format, operator, val;
368
369
  $form = $(element[0].form);
369
- val = $.trim(element.val());
370
370
  number_format = $form[0].ClientSideValidations.settings.number_format;
371
- if (!ClientSideValidations.patterns.numericality(number_format).test(val)) {
371
+ val = $.trim(element.val()).replace(new RegExp("\\" + number_format.separator, 'g'), '.');
372
+ if (options.only_integer && !ClientSideValidations.patterns.numericality.only_integer.test(val)) {
373
+ return options.messages.only_integer;
374
+ }
375
+ if (!ClientSideValidations.patterns.numericality["default"].test(val)) {
372
376
  if (options.allow_blank === true && this.presence(element, {
373
377
  message: options.messages.numericality
374
378
  })) {
@@ -376,10 +380,6 @@
376
380
  }
377
381
  return options.messages.numericality;
378
382
  }
379
- val = val.replace(new RegExp("\\" + number_format.delimiter, 'g'), '').replace(new RegExp("\\" + number_format.separator, 'g'), '.');
380
- if (options.only_integer && !/^[+-]?\d+$/.test(val)) {
381
- return options.messages.only_integer;
382
- }
383
383
  CHECKS = {
384
384
  greater_than: '>',
385
385
  greater_than_or_equal_to: '>=',
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: 9.3.4
4
+ version: 10.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: 2017-07-15 00:00:00.000000000 Z
12
+ date: 2017-10-09 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: '1.2'
54
+ version: '2.0'
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: '1.2'
61
+ version: '2.0'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: appraisal
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -79,14 +79,14 @@ dependencies:
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '9.0'
82
+ version: '9.1'
83
83
  type: :development
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '9.0'
89
+ version: '9.1'
90
90
  - !ruby/object:Gem::Dependency
91
91
  name: coveralls
92
92
  requirement: !ruby/object:Gem::Requirement
@@ -135,42 +135,42 @@ dependencies:
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '1.2'
138
+ version: '1.3'
139
139
  type: :development
140
140
  prerelease: false
141
141
  version_requirements: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '1.2'
145
+ version: '1.3'
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: rake
148
148
  requirement: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '12.0'
152
+ version: '12.1'
153
153
  type: :development
154
154
  prerelease: false
155
155
  version_requirements: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '12.0'
159
+ version: '12.1'
160
160
  - !ruby/object:Gem::Dependency
161
161
  name: rubocop
162
162
  requirement: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 0.49.1
166
+ version: 0.50.0
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.49.1
173
+ version: 0.50.0
174
174
  - !ruby/object:Gem::Dependency
175
175
  name: simplecov
176
176
  requirement: !ruby/object:Gem::Requirement
@@ -316,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
316
  version: '0'
317
317
  requirements: []
318
318
  rubyforge_project:
319
- rubygems_version: 2.6.12
319
+ rubygems_version: 2.6.13
320
320
  signing_key:
321
321
  specification_version: 4
322
322
  summary: Client Side Validations