-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/on all fields filled #42
Open
JasonTsao
wants to merge
10
commits into
heilhead:master
Choose a base branch
from
unknown repository
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3f540a0
feature/onAllFieldsFilled upping package version
JasonTsao c34eb19
feature/onAllFieldsFilled adding validateAllOnValidationEvent behavior
JasonTsao 38ffcb3
feature/onAllFieldsFilled updating urls pointing at for package
JasonTsao 23d0b75
feature/onAllFieldsFilled removing src from npm ignore
JasonTsao 8d5ea67
feature/onAllFieldsFilled adding control to setError on fields or not
JasonTsao e808f58
feature/onAllFieldsFilled valid checking on success and failure cases
JasonTsao 7ed0a49
feature/onAllFieldsFilled changing package json back
JasonTsao 98852b4
feature/onAllFieldsFilled fixing spacing
JasonTsao ed795ef
feature/onAllFieldsFilled removing unnecessary things
JasonTsao ae2df12
feature/onAllFieldsFilled fixing spacing again
JasonTsao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
{ | ||
"name": "react-bootstrap-validation", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"description": "Form validation for react-bootstrap", | ||
"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 <[email protected]>", | ||
"license": "MIT", | ||
"homepage": "https://github.com/heilhead/react-bootstrap-validation", | ||
"homepage": "https://github.com/MakerStudios/react-bootstrap-validation", | ||
"peerDependencies": { | ||
"react": ">=0.13" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,7 +149,14 @@ export default class Form extends InputContainer { | |
} | ||
|
||
_validateInput(name) { | ||
this._validateOne(name, this.getValues()); | ||
let result = this._validateOne(name, this.getValues()); | ||
|
||
if (typeof this.props.validateAllCallback === 'function') { | ||
let values = this.getValues(); | ||
let { isValid, errors } = this._validateAll(values, false); | ||
|
||
this.props.validateAllCallback(isValid); | ||
} | ||
} | ||
|
||
_hasError(iptName) { | ||
|
@@ -175,7 +182,7 @@ export default class Form extends InputContainer { | |
}); | ||
} | ||
|
||
_validateOne(iptName, context) { | ||
_validateOne(iptName, context, setError=true) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make sure the argument in the function has proper spacing, |
||
let input = this._inputs[iptName]; | ||
|
||
if (Array.isArray(input)) { | ||
|
@@ -189,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 { | ||
|
@@ -210,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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same thing about spaces between assignment |
||
let isValid = true; | ||
let errors = []; | ||
|
||
|
@@ -233,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); | ||
} | ||
|
@@ -331,6 +340,7 @@ 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' | ||
]), | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errors
is unused here