From 3f540a00bc0a85e503f3f3b054845013b61d6aa2 Mon Sep 17 00:00:00 2001 From: JasonTsao Date: Thu, 24 Mar 2016 10:56:12 -0700 Subject: [PATCH 01/10] feature/onAllFieldsFilled upping package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0089653..4dd4e41 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-bootstrap-validation", - "version": "0.1.11", + "version": "0.1.12", "description": "Form validation for react-bootstrap", "main": "./lib/index.js", "repository": { From c34eb194250907b75474409e0c6db8cf8d216dad Mon Sep 17 00:00:00 2001 From: JasonTsao Date: Thu, 24 Mar 2016 13:59:20 -0700 Subject: [PATCH 02/10] feature/onAllFieldsFilled adding validateAllOnValidationEvent behavior --- src/Form.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Form.js b/src/Form.js index 3a27772..5efb886 100644 --- a/src/Form.js +++ b/src/Form.js @@ -149,7 +149,16 @@ export default class Form extends InputContainer { } _validateInput(name) { - this._validateOne(name, this.getValues()); + result = this._validateOne(name, this.getValues()); + + if (result && typeof this.props.validateAllOnValidationEvent === 'function') { + let values = this.getValues(); + let { allAreValid, errors } = this._validateAll(values); + + if (allAreValid) { + this.props.validateAllCallback(allAreValid); + } + } } _hasError(iptName) { @@ -189,8 +198,8 @@ export default class Form extends InputContainer { let validate = input.props.validate; let result, error; - if (typeof validate === 'function') { - result = validate(value, context); + if (typeof validate === 'function') { + result = validate(value, context); } else if (typeof validate === 'string') { result = this._validators[iptName](value); } else { @@ -331,9 +340,11 @@ Form.propTypes = { onInvalidSubmit: React.PropTypes.func, validateOne : React.PropTypes.func, validateAll : React.PropTypes.func, + validateAllCallback: React.PropTypes.func, validationEvent: React.PropTypes.oneOf([ 'onChange', 'onBlur', 'onFocus' ]), + validateAllOnValidationEvent: React.PropTypes.bool, errorHelp : React.PropTypes.oneOfType([ React.PropTypes.string, React.PropTypes.object @@ -343,5 +354,7 @@ Form.propTypes = { Form.defaultProps = { model : {}, validationEvent: 'onChange', + validateAllOnValidationEvent: false, + validateAllCallback: () => {}, onInvalidSubmit: () => {} }; From 38ffcb3b6063dd1de7ea7bd20ebdc162b9766b2c Mon Sep 17 00:00:00 2001 From: JasonTsao Date: Thu, 24 Mar 2016 15:39:27 -0700 Subject: [PATCH 03/10] feature/onAllFieldsFilled updating urls pointing at for package --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 4dd4e41..19c4e05 100644 --- a/package.json +++ b/package.json @@ -5,10 +5,10 @@ "main": "./lib/index.js", "repository": { "type": "git", - "url": "https://github.com/heilhead/react-bootstrap-validation.git" + "url": "https://github.com/MakerStudios/react-bootstrap-validation.git" }, "bugs": { - "url": "https://github.com/heilhead/react-bootstrap-validation/issues" + "url": "https://github.com/MakerStudios/react-bootstrap-validation/issues" }, "directories": { "lib": "lib/" @@ -25,7 +25,7 @@ ], "author": "Ivan Reshetnikov ", "license": "MIT", - "homepage": "https://github.com/heilhead/react-bootstrap-validation", + "homepage": "https://github.com/MakerStudios/react-bootstrap-validation", "peerDependencies": { "react": ">=0.13" }, From 23d0b7566fe77bf6deec5461d52d5b445f567b8d Mon Sep 17 00:00:00 2001 From: JasonTsao Date: Thu, 24 Mar 2016 17:00:47 -0700 Subject: [PATCH 04/10] feature/onAllFieldsFilled removing src from npm ignore --- .npmignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.npmignore b/.npmignore index c05a253..13e49c4 100644 --- a/.npmignore +++ b/.npmignore @@ -5,7 +5,6 @@ node_modules .idea/ .babel-cache/ .coverage/ -src/ .npmignore gulpfile.js .eslintrc \ No newline at end of file From 8d5ea67eedf505b4b19735bd9413a765e4758833 Mon Sep 17 00:00:00 2001 From: JasonTsao Date: Fri, 25 Mar 2016 11:19:26 -0700 Subject: [PATCH 05/10] feature/onAllFieldsFilled adding control to setError on fields or not --- .npmignore | 1 + src/Form.js | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.npmignore b/.npmignore index 13e49c4..c05a253 100644 --- a/.npmignore +++ b/.npmignore @@ -5,6 +5,7 @@ node_modules .idea/ .babel-cache/ .coverage/ +src/ .npmignore gulpfile.js .eslintrc \ No newline at end of file diff --git a/src/Form.js b/src/Form.js index 5efb886..43f6fe0 100644 --- a/src/Form.js +++ b/src/Form.js @@ -149,15 +149,13 @@ export default class Form extends InputContainer { } _validateInput(name) { - result = this._validateOne(name, this.getValues()); + let result = this._validateOne(name, this.getValues()); - if (result && typeof this.props.validateAllOnValidationEvent === 'function') { + if (result && typeof this.props.validateAllCallback === 'function') { let values = this.getValues(); - let { allAreValid, errors } = this._validateAll(values); + let { isValid, errors } = this._validateAll(values, false); - if (allAreValid) { - this.props.validateAllCallback(allAreValid); - } + this.props.validateAllCallback(isValid); } } @@ -184,7 +182,7 @@ export default class Form extends InputContainer { }); } - _validateOne(iptName, context) { + _validateOne(iptName, context, setError=true) { let input = this._inputs[iptName]; if (Array.isArray(input)) { @@ -219,12 +217,14 @@ export default class Form extends InputContainer { } } - this._setError(iptName, !isValid, error); + if (setError) { + this._setError(iptName, !isValid, error); + } return isValid; } - _validateAll(context) { + _validateAll(context, setError=true) { let isValid = true; let errors = []; @@ -242,7 +242,7 @@ export default class Form extends InputContainer { } } else { Object.keys(this._inputs).forEach(iptName => { - if (!this._validateOne(iptName, context)) { + if (!this._validateOne(iptName, context, setError)) { isValid = false; errors.push(iptName); } @@ -344,7 +344,6 @@ Form.propTypes = { validationEvent: React.PropTypes.oneOf([ 'onChange', 'onBlur', 'onFocus' ]), - validateAllOnValidationEvent: React.PropTypes.bool, errorHelp : React.PropTypes.oneOfType([ React.PropTypes.string, React.PropTypes.object @@ -354,7 +353,5 @@ Form.propTypes = { Form.defaultProps = { model : {}, validationEvent: 'onChange', - validateAllOnValidationEvent: false, - validateAllCallback: () => {}, onInvalidSubmit: () => {} }; From e808f58ce0561270cea8e2bc81cd0dc1da71d6dc Mon Sep 17 00:00:00 2001 From: JasonTsao Date: Fri, 25 Mar 2016 16:07:46 -0700 Subject: [PATCH 06/10] feature/onAllFieldsFilled valid checking on success and failure cases --- src/Form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Form.js b/src/Form.js index 43f6fe0..0c32cb2 100644 --- a/src/Form.js +++ b/src/Form.js @@ -151,7 +151,7 @@ export default class Form extends InputContainer { _validateInput(name) { let result = this._validateOne(name, this.getValues()); - if (result && typeof this.props.validateAllCallback === 'function') { + if (typeof this.props.validateAllCallback === 'function') { let values = this.getValues(); let { isValid, errors } = this._validateAll(values, false); From 7ed0a49739e08d9f9f9027c7d29e32eb8de966de Mon Sep 17 00:00:00 2001 From: JasonTsao Date: Fri, 25 Mar 2016 16:13:26 -0700 Subject: [PATCH 07/10] feature/onAllFieldsFilled changing package json back --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 19c4e05..8fb3cd9 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { "name": "react-bootstrap-validation", - "version": "0.1.12", + "version": "0.1.11", "description": "Form validation for react-bootstrap", "main": "./lib/index.js", "repository": { "type": "git", - "url": "https://github.com/MakerStudios/react-bootstrap-validation.git" + "url": "https://github.com/heilhead/react-bootstrap-validation.git" }, "bugs": { - "url": "https://github.com/MakerStudios/react-bootstrap-validation/issues" + "url": "https://github.com/heilhead/react-bootstrap-validation/issues" }, "directories": { "lib": "lib/" @@ -25,7 +25,7 @@ ], "author": "Ivan Reshetnikov ", "license": "MIT", - "homepage": "https://github.com/MakerStudios/react-bootstrap-validation", + "homepage": "https://github.com/heilhead/react-bootstrap-validation", "peerDependencies": { "react": ">=0.13" }, @@ -49,4 +49,4 @@ "validator": "^3.41.3", "react-addons-create-fragment": "^0.14.7" } -} +} \ No newline at end of file From 98852b412deb8178be1598b95911c45a28cef4c3 Mon Sep 17 00:00:00 2001 From: JasonTsao Date: Fri, 25 Mar 2016 16:19:40 -0700 Subject: [PATCH 08/10] feature/onAllFieldsFilled fixing spacing --- src/Form.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Form.js b/src/Form.js index 0c32cb2..77901f4 100644 --- a/src/Form.js +++ b/src/Form.js @@ -182,7 +182,7 @@ export default class Form extends InputContainer { }); } - _validateOne(iptName, context, setError=true) { + _validateOne(iptName, context, setError = true) { let input = this._inputs[iptName]; if (Array.isArray(input)) { @@ -196,8 +196,8 @@ export default class Form extends InputContainer { let validate = input.props.validate; let result, error; - if (typeof validate === 'function') { - result = validate(value, context); + if (typeof validate === 'function') { + result = validate(value, context); } else if (typeof validate === 'string') { result = this._validators[iptName](value); } else { From ed795ef63d8ee5c44506fb006d46781112e51a69 Mon Sep 17 00:00:00 2001 From: JasonTsao Date: Fri, 25 Mar 2016 16:21:24 -0700 Subject: [PATCH 09/10] feature/onAllFieldsFilled removing unnecessary things --- src/Form.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Form.js b/src/Form.js index 77901f4..237b041 100644 --- a/src/Form.js +++ b/src/Form.js @@ -149,11 +149,11 @@ export default class Form extends InputContainer { } _validateInput(name) { - let result = this._validateOne(name, this.getValues()); + this._validateOne(name, this.getValues()); if (typeof this.props.validateAllCallback === 'function') { let values = this.getValues(); - let { isValid, errors } = this._validateAll(values, false); + let { isValid } = this._validateAll(values, false); this.props.validateAllCallback(isValid); } From ae2df12d655fb3f750aa595b166fbdf6ed1e7cd0 Mon Sep 17 00:00:00 2001 From: JasonTsao Date: Fri, 25 Mar 2016 16:22:22 -0700 Subject: [PATCH 10/10] feature/onAllFieldsFilled fixing spacing again --- src/Form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Form.js b/src/Form.js index 237b041..5d3b4fb 100644 --- a/src/Form.js +++ b/src/Form.js @@ -224,7 +224,7 @@ export default class Form extends InputContainer { return isValid; } - _validateAll(context, setError=true) { + _validateAll(context, setError = true) { let isValid = true; let errors = [];