diff --git a/src/main.js b/src/main.js index 98f0eae..f0a8b91 100644 --- a/src/main.js +++ b/src/main.js @@ -127,13 +127,7 @@ Formsy.Mixin = { componentWillMount: function () { var configure = function () { - // Add validations to the store itself as the props object can not be modified - this._validations = this.props.validations || ''; - - if (this.props.required) { - this._validations = this.props.validations ? this.props.validations + ',' : ''; - this._validations += 'isValue'; - } + this.setValidations(); this.props._attachToForm(this); }.bind(this); @@ -158,6 +152,7 @@ Formsy.Mixin = { nextProps._attachToForm = this.props._attachToForm; nextProps._detachFromForm = this.props._detachFromForm; nextProps._validate = this.props._validate; + this.setValidations(); }, componentDidUpdate: function(prevProps, prevState) { @@ -177,6 +172,16 @@ Formsy.Mixin = { this.props._detachFromForm(this); }, + setValidations: function() { + // Add validations to the store itself as the props object can not be modified + this._validations = this.props.validations || ''; + + if (this.props.required) { + this._validations = this.props.validations ? this.props.validations + ',' : ''; + this._validations += 'isValue'; + } + }, + // We validate after the value has been set setValue: function (value) { this.setState({