Merge branch 'react-0.14' of https://github.com/christianalfoni/formsy-react into react-0.14
This commit is contained in:
commit
619a85657f
|
|
@ -22,6 +22,12 @@
|
|||
"validation",
|
||||
"react-component"
|
||||
],
|
||||
"dependencies": {
|
||||
"form-data-to-object": "^0.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^0.14.0-beta1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel": "^5.6.4",
|
||||
"babel-core": "^5.1.11",
|
||||
|
|
|
|||
|
|
@ -140,10 +140,11 @@ module.exports = {
|
|||
return this.state._value !== '';
|
||||
},
|
||||
getErrorMessage: function () {
|
||||
return this.getErrorMessages() && this.getErrorMessages()[0];
|
||||
var messages = this.getErrorMessages();
|
||||
return messages.length ? messages[0] : null;
|
||||
},
|
||||
getErrorMessages: function () {
|
||||
return !this.isValid() || this.showRequired() ? (this.state._externalError || this.state._validationError) : null;
|
||||
return !this.isValid() || this.showRequired() ? (this.state._externalError || this.state._validationError || []) : [];
|
||||
},
|
||||
isFormDisabled: function () {
|
||||
return this.context.formsy.isFormDisabled();
|
||||
|
|
|
|||
12
src/main.js
12
src/main.js
|
|
@ -321,11 +321,17 @@ Formsy.Form = React.createClass({
|
|||
}
|
||||
|
||||
if (isRequired) {
|
||||
return [validationErrors[requiredResults.success[0]]] || null;
|
||||
var error = validationErrors[requiredResults.success[0]];
|
||||
return error ? [error] : null;
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
return [validationError];
|
||||
if (validationResults.failed.length) {
|
||||
return validationResults.failed.map(function(failed) {
|
||||
return validationErrors[failed] ? validationErrors[failed] : validationError;
|
||||
}).filter(function(x, pos, arr) {
|
||||
// Remove duplicates
|
||||
return arr.indexOf(x) === pos;
|
||||
});
|
||||
}
|
||||
|
||||
}.call(this))
|
||||
|
|
|
|||
Loading…
Reference in New Issue