diff --git a/specs/Validation-spec.js b/specs/Validation-spec.js
index 75e96eb..2876286 100644
--- a/specs/Validation-spec.js
+++ b/specs/Validation-spec.js
@@ -162,4 +162,32 @@ describe('Validation', function() {
});
+ it('RULE: isNumeric is false (string representation of an invalid 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.'}});
+ expect(isValid).not.toHaveBeenCalled();
+
+ });
+
});
diff --git a/src/main.js b/src/main.js
index 97eb031..934fe60 100644
--- a/src/main.js
+++ b/src/main.js
@@ -14,7 +14,12 @@ var validationRules = {
if (typeof value === 'number') {
return true;
} else {
- return value.match(/[-+]?(\d*[.])?\d+/);
+ matchResults = value.match(/[-+]?(\d*[.])?\d+/);
+ if (!! matchResults) {
+ return matchResults[0] == value;
+ } else {
+ return false;
+ }
}
},
'isAlpha': function (value) {