client_side_validations 3.1.3 → 3.1.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -2,14 +2,14 @@ module('Numericality options');
|
|
2
2
|
|
3
3
|
test('when value is a number', function() {
|
4
4
|
var element = $('<input type="text" />');
|
5
|
-
var options = {
|
5
|
+
var options = { messagess: { numericality: "failed validation" } };
|
6
6
|
element.val('123');
|
7
7
|
equal(clientSideValidations.validators.local.numericality(element, options), undefined);
|
8
8
|
});
|
9
9
|
|
10
10
|
test('when value is a decimal number', function() {
|
11
11
|
var element = $('<input type="text" />');
|
12
|
-
var options = {
|
12
|
+
var options = { messages: { numericality: "failed validation" } };
|
13
13
|
element.val('123.456');
|
14
14
|
equal(clientSideValidations.validators.local.numericality(element, options), undefined);
|
15
15
|
});
|
@@ -149,3 +149,10 @@ test('when only allowing even values and the value is odd', function() {
|
|
149
149
|
equal(clientSideValidations.validators.local.numericality(element, options), "failed validation");
|
150
150
|
});
|
151
151
|
|
152
|
+
test('blank values should be evaluated as zero', function() {
|
153
|
+
var element = $('<input type="text" />');
|
154
|
+
var options = { messages: { numericality: "failed validation" } };
|
155
|
+
element.val('');
|
156
|
+
equal(clientSideValidations.validators.local.numericality(element, options), undefined);
|
157
|
+
});
|
158
|
+
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* Rails 3 Client Side Validations - v3.1.
|
2
|
+
* Rails 3 Client Side Validations - v3.1.4
|
3
3
|
* https://github.com/bcardarlela/client_side_validations
|
4
4
|
*
|
5
5
|
* Copyright (c) 2011 Brian Cardarella
|
@@ -15,8 +15,8 @@
|
|
15
15
|
|
16
16
|
// Set up the events for the form
|
17
17
|
form
|
18
|
-
.submit(function()
|
19
|
-
.bind('ajax:beforeSend', function()
|
18
|
+
.submit( function() { return form.isValid(settings.validators); })
|
19
|
+
.bind('ajax:beforeSend', function(eventData) { if(eventData.target == this) return form.isValid(settings.validators); })
|
20
20
|
// Callbacks
|
21
21
|
.bind('form:validate:after', function(eventData) { clientSideValidations.callbacks.form.after( form, eventData); })
|
22
22
|
.bind('form:validate:before', function(eventData) { clientSideValidations.callbacks.form.before(form, eventData); })
|
@@ -161,7 +161,7 @@ var clientSideValidations = {
|
|
161
161
|
}
|
162
162
|
},
|
163
163
|
numericality: function(element, options) {
|
164
|
-
if (!/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d*)?$/.test(element.val())) {
|
164
|
+
if (!/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d*)?$/.test(element.val()) && element.val() != '') {
|
165
165
|
return options.messages.numericality;
|
166
166
|
}
|
167
167
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: client_side_validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 3.1.
|
5
|
+
version: 3.1.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brian Cardarella
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-12-22 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|