af-client_side_validations 3.1.4.af1 → 3.1.4.af2

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.
@@ -10,6 +10,7 @@ module ClientSideValidations::ActiveModel
10
10
  def client_side_hash(model, attribute)
11
11
  options = self.options.dup
12
12
  hash = { :messages => { :numericality => model.errors.generate_message(attribute, :not_a_number, options) } }
13
+ hash[:allow_blank] = options[:allow_blank] if options[:allow_blank]
13
14
 
14
15
  if options[:only_integer]
15
16
  hash[:messages][:only_integer] = model.errors.generate_message(attribute, :not_an_integer, options)
@@ -1,3 +1,3 @@
1
1
  module ClientSideValidations
2
- VERSION = '3.1.4.af1'
2
+ VERSION = '3.1.4.af2'
3
3
  end
@@ -166,7 +166,11 @@ var clientSideValidations = {
166
166
  }
167
167
  },
168
168
  numericality: function(element, options) {
169
- if (!/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d*)?$/.test(element.val()) && element.val() != '') {
169
+ if (options.allow_blank === true && /^\s*$/.test(element.val() || "")) {
170
+ return;
171
+ }
172
+
173
+ if (!/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d*)?$/.test(element.val())) {
170
174
  return options.messages.numericality;
171
175
  }
172
176
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: af-client_side_validations
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1294307170
4
+ hash: -1722129574
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
9
  - 4
10
10
  - af
11
- - 1
12
- version: 3.1.4.af1
11
+ - 2
12
+ version: 3.1.4.af2
13
13
  platform: ruby
14
14
  authors:
15
15
  - Paul Kmiec