diff --git a/demo/demo.js b/demo/demo.js index 14aa652..c99eafe 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -313,7 +313,6 @@ change: _this.virtualServerCallback, propName: 'text', className: _this.state.highlight ? "editable" : "", - validate: _this.isStringAcceptable, classLoading: 'loading', classInvalid: 'invalid', isDisabled: _this.state.isDisabled }), @@ -19352,15 +19351,16 @@ _this.doValidations = function (value) { debug('doValidations(' + value + ')'); - var result = void 0; + var isValid = void 0; if (_this.props.validate) { - result = _this.props.validate(value); + debug('using this.props.validate'); + isValid = _this.props.validate(value); } else if (_this.validate) { - result = _this.validate(value); - } - _this.setState({ invalid: !result }); - - return result; + debug('using this.validate'); + isValid = _this.validate(value); + } else return true; + _this.setState({ invalid: !isValid }); + return isValid; }; _this.selectInputText = function (element) { diff --git a/demo/demo.jsx b/demo/demo.jsx index 2a5d882..0202537 100644 --- a/demo/demo.jsx +++ b/demo/demo.jsx @@ -147,7 +147,6 @@ isDisabled={this.state.isDisabled} />`} change={this.virtualServerCallback} propName="text" className={this.state.highlight ? "editable" : ""} - validate={this.isStringAcceptable} classLoading="loading" classInvalid="invalid" isDisabled={this.state.isDisabled} /> diff --git a/src/RIEBase.js b/src/RIEBase.js index 37b7d4a..a616aca 100644 --- a/src/RIEBase.js +++ b/src/RIEBase.js @@ -43,15 +43,16 @@ export default class RIEBase extends React.Component { doValidations = (value) => { debug(`doValidations(${value})`) - let result; + let isValid; if(this.props.validate) { - result = this.props.validate(value); + debug('using this.props.validate') + isValid = this.props.validate(value); } else if (this.validate) { - result = this.validate(value); - } - this.setState({invalid: !result}); - - return result; + debug('using this.validate') + isValid = this.validate(value); + } else return true + this.setState({invalid: !isValid}); + return isValid; }; selectInputText = (element) => {