af-client_side_validations 3.1.4.af1 → 3.1.4.af2
Sign up to get free protection for your applications and to get access to all the features.
@@ -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)
|
@@ -166,7 +166,11 @@ var clientSideValidations = {
|
|
166
166
|
}
|
167
167
|
},
|
168
168
|
numericality: function(element, options) {
|
169
|
-
if (
|
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: -
|
4
|
+
hash: -1722129574
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
9
|
- 4
|
10
10
|
- af
|
11
|
-
-
|
12
|
-
version: 3.1.4.
|
11
|
+
- 2
|
12
|
+
version: 3.1.4.af2
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Paul Kmiec
|