diff --git a/API.md b/API.md index 2bbb8f1..1a31266 100644 --- a/API.md +++ b/API.md @@ -212,7 +212,7 @@ You should always use the [**getValue()**](#getvalue) method inside your formsy } }}/> ``` -An comma seperated list with validation rules. Take a look at [**Validators**](#validators) to see default rules. Use ":" to separate argument passed to the validator. The argument will go through a **JSON.parse** converting them into correct JavaScript types. Meaning: +An comma separated list with validation rules. Take a look at [**Validators**](#validators) to see default rules. Use ":" to separate argument passed to the validator. The argument will go through a **JSON.parse** converting them into correct JavaScript types. Meaning: ```html diff --git a/README.md b/README.md index 7571ecf..d102b58 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -formsy-react [![GitHub release](https://img.shields.io/github/release/christianalfoni/formsy-react.svg)](https://github.com/christianalfoni/formsy-react/releases) ![build](https://travis-ci.org/christianalfoni/formsy-react.svg) +formsy-react [![GitHub release](https://img.shields.io/github/release/christianalfoni/formsy-react.svg)](https://github.com/christianalfoni/formsy-react/releases) [![Build Status](https://travis-ci.org/christianalfoni/formsy-react.svg?branch=master)](https://travis-ci.org/christianalfoni/formsy-react) ============ A form input builder and validator for React JS diff --git a/package.json b/package.json index d74bf42..703ad46 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,12 @@ "babel-loader": "^5.0.0", "jasmine-node": "^1.14.5", "jsdom": "^3.1.2", - "react": "^0.14.0-beta1", - "react-dom": "^0.14.0-beta1", + "react": "^0.14.0-beta3" + "react-dom": "^0.14.0-beta3", "webpack": "^1.7.3", "webpack-dev-server": "^1.7.0" + }, + "peerDependencies": { + "react": "^0.14.0-beta3" } } diff --git a/specs/Element-spec.jsx b/specs/Element-spec.jsx index ec2d3f2..d09746d 100644 --- a/specs/Element-spec.jsx +++ b/specs/Element-spec.jsx @@ -198,8 +198,11 @@ describe('Element', function() { it('should allow an undefined value to be updated to a value', function (done) { var TestInput = React.createClass({ mixins: [Formsy.Mixin], + changeValue: function (event) { + this.setValue(event.target.value); + }, render: function () { - return + return } }); var TestForm = React.createClass({ @@ -237,7 +240,7 @@ it('should allow an undefined value to be updated to a value', function (done) { var TestInput = React.createClass({ mixins: [Formsy.Mixin], render: function () { - return + return } }); var TestForm = React.createClass({ @@ -264,7 +267,7 @@ it('should allow an undefined value to be updated to a value', function (done) { var TestInput = React.createClass({ mixins: [Formsy.Mixin], render: function () { - return + return } }); var TestForm = React.createClass({ @@ -368,7 +371,7 @@ it('should allow an undefined value to be updated to a value', function (done) { var TestInput = React.createClass({ mixins: [Formsy.Mixin], render: function () { - return + return } }); var TestForm = React.createClass({ @@ -394,7 +397,7 @@ it('should allow an undefined value to be updated to a value', function (done) { var TestInput = React.createClass({ mixins: [Formsy.Mixin], render: function () { - return + return } }); var TestForm = React.createClass({ @@ -428,7 +431,7 @@ it('should allow an undefined value to be updated to a value', function (done) { var TestInput = React.createClass({ mixins: [Formsy.Mixin], render: function () { - return + return } }); var TestForm = React.createClass({ @@ -459,7 +462,7 @@ it('should allow an undefined value to be updated to a value', function (done) { var TestInput = React.createClass({ mixins: [Formsy.Mixin], render: function () { - return + return } }); var TestForm = React.createClass({ diff --git a/specs/Formsy-spec.jsx b/specs/Formsy-spec.jsx index 5d51f43..d9d67fa 100755 --- a/specs/Formsy-spec.jsx +++ b/specs/Formsy-spec.jsx @@ -84,7 +84,7 @@ describe('Formsy', function () { // Wait before adding the input setTimeout(function () { - inputs.push(); + inputs.push(); forceUpdate(function () { // Wait for next event loop, as that does the form @@ -135,7 +135,7 @@ describe('Formsy', function () { // Wait before adding the input setTimeout(function () { - inputs.push(); + inputs.push(); forceUpdate(function () { @@ -378,7 +378,7 @@ describe('Formsy', function () { ); // Wait before adding the input - inputs.push(); + inputs.push(); forceUpdate(function () { @@ -401,7 +401,7 @@ describe('Formsy', function () { var TestInput = React.createClass({ mixins: [Formsy.Mixin], render: function () { - return + return } }); var TestForm = React.createClass({ @@ -439,7 +439,7 @@ describe('Formsy', function () { var TestInput = React.createClass({ mixins: [Formsy.Mixin], render: function () { - return ; + return ; } }); var TestForm = React.createClass({ @@ -494,7 +494,7 @@ describe('Formsy', function () { var TestInput = React.createClass({ mixins: [Formsy.Mixin], render: function () { - return ; + return ; } }); var TestForm = React.createClass({ @@ -524,7 +524,7 @@ describe('Formsy', function () { var TestInput = React.createClass({ mixins: [Formsy.Mixin], render: function () { - return ; + return ; } }); var TestForm = React.createClass({ diff --git a/specs/Validation-spec.jsx b/specs/Validation-spec.jsx index cf92542..fd6fabe 100644 --- a/specs/Validation-spec.jsx +++ b/specs/Validation-spec.jsx @@ -160,7 +160,7 @@ describe('Validation', function() { var TestInput = React.createClass({ mixins: [Formsy.Mixin], render: function () { - return + return } }); var TestForm = React.createClass({ @@ -191,7 +191,7 @@ describe('Validation', function() { var TestInput = React.createClass({ mixins: [Formsy.Mixin], render: function () { - return + return } }); var TestForm = React.createClass({ @@ -223,7 +223,7 @@ describe('Validation', function() { var TestInput = React.createClass({ mixins: [Formsy.Mixin], render: function () { - return + return } }); var TestForm = React.createClass({ @@ -253,7 +253,7 @@ describe('Validation', function() { var TestInput = React.createClass({ mixins: [Formsy.Mixin], render: function () { - return + return } }); var TestForm = React.createClass({ diff --git a/src/main.js b/src/main.js index 8c2e345..b8e9bfe 100644 --- a/src/main.js +++ b/src/main.js @@ -393,17 +393,15 @@ Formsy.Form = React.createClass({ // Validate the form by going through all child input components // and check their state validateForm: function () { - var allIsValid = true; + var allIsValid; var inputs = this.inputs; var inputKeys = Object.keys(inputs); // We need a callback as we are validating all inputs again. This will // run when the last component has set its state var onValidationComplete = function () { - inputKeys.forEach(function (name) { - if (!inputs[name].state._isValid) { - allIsValid = false; - } + allIsValid = inputKeys.every(function (name) { + return inputs[name].state._isValid; }.bind(this)); this.setState({