diff --git a/specs/Validation-spec.js b/specs/Validation-spec.js
index 446961f..75e96eb 100644
--- a/specs/Validation-spec.js
+++ b/specs/Validation-spec.js
@@ -3,7 +3,7 @@ var Formsy = require('./../src/main.js');
describe('Validation', function() {
it('should trigger an onValid handler, if passed, when form is valid', function () {
-
+
var onValid = jasmine.createSpy('valid');
var TestInput = React.createClass({
mixins: [Formsy.Mixin],
@@ -27,7 +27,7 @@ describe('Validation', function() {
});
it('should trigger an onInvalid handler, if passed, when form is invalid', function () {
-
+
var onInvalid = jasmine.createSpy('invalid');
var TestInput = React.createClass({
mixins: [Formsy.Mixin],
@@ -51,7 +51,7 @@ describe('Validation', function() {
});
it('RULE: isEmail', function () {
-
+
var isValid = jasmine.createSpy('valid');
var TestInput = React.createClass({
mixins: [Formsy.Mixin],
@@ -79,7 +79,7 @@ describe('Validation', function() {
});
it('RULE: isNumeric', function () {
-
+
var isValid = jasmine.createSpy('valid');
var TestInput = React.createClass({
mixins: [Formsy.Mixin],
@@ -107,7 +107,7 @@ describe('Validation', function() {
});
it('RULE: isNumeric (actual number)', function () {
-
+
var isValid = jasmine.createSpy('valid');
var TestInput = React.createClass({
mixins: [Formsy.Mixin],
@@ -134,4 +134,32 @@ describe('Validation', function() {
});
+ it('RULE: isNumeric (string representation of a float)', function () {
+
+ var isValid = jasmine.createSpy('valid');
+ var TestInput = React.createClass({
+ mixins: [Formsy.Mixin],
+ updateValue: function (event) {
+ this.setValue(event.target.value);
+ },
+ render: function () {
+ if (this.isValid()) {
+ isValid();
+ }
+ return
+ }
+ });
+ var form = TestUtils.renderIntoDocument(
+
+
+
+ );
+
+ var input = TestUtils.findRenderedDOMComponentWithTag(form, 'INPUT');
+ expect(isValid).not.toHaveBeenCalled();
+ TestUtils.Simulate.change(input, {target: {value: '1.5'}});
+ expect(isValid).toHaveBeenCalled();
+
+ });
+
});
diff --git a/src/main.js b/src/main.js
index 0bd844e..97eb031 100644
--- a/src/main.js
+++ b/src/main.js
@@ -14,7 +14,7 @@ var validationRules = {
if (typeof value === 'number') {
return true;
} else {
- return value.match(/^-?[0-9]+$/);
+ return value.match(/[-+]?(\d*[.])?\d+/);
}
},
'isAlpha': function (value) {