(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 1) { throw new Error('Formsy does not support multiple args on string validations. Use object format of validations instead.'); } validations[validateMethod] = args[0] || true; return validations; }, {}); } return validations || {}; }; module.exports = { getInitialState: function () { return { _value: this.props.value, _isRequired: false, _isValid: true, _isPristine: true, _pristineValue: this.props.value, _validationError: '' }; }, getDefaultProps: function () { return { validationError: '', validationErrors: {} }; }, componentWillMount: function () { var configure = function () { this.setValidations(this.props.validations, this.props.required); this.props._attachToForm(this); }.bind(this); if (!this.props.name) { throw new Error('Form Input requires a name property when used'); } if (!this.props._attachToForm) { return setTimeout(function () { if (!this.isMounted()) return; if (!this.props._attachToForm) { throw new Error('Form Mixin requires component to be nested in a Form'); } configure(); }.bind(this), 0); } configure(); }, // We have to make the validate method is kept when new props are added componentWillReceiveProps: function (nextProps) { nextProps._attachToForm = this.props._attachToForm; nextProps._detachFromForm = this.props._detachFromForm; nextProps._validate = this.props._validate; nextProps._isValidValue = this.props._isValidValue; nextProps._isFormDisabled = this.props._isFormDisabled; this.setValidations(nextProps.validations, nextProps.required); }, componentDidUpdate: function (prevProps, prevState) { var isValueChanged = function () { return this.props.value !== prevProps.value && this.state._value === prevProps.value; }.bind(this); // If validations has changed or something outside changes // the value, set the value again running a validation if (prevProps.validations !== this.props.validations || isValueChanged()) { this.setValue(this.props.value); } }, // Detach it when component unmounts componentWillUnmount: function () { this.props._detachFromForm(this); }, setValidations: function (validations, required) { // Add validations to the store itself as the props object can not be modified this._validations = convertValidationsToObject(validations) || {}; this._requiredValidations = required === true ? {isDefaultRequiredValue: true} : convertValidationsToObject(required); }, // We validate after the value has been set setValue: function (value) { this.setState({ _value: value, _isPristine: false }, function () { this.props._validate(this); }.bind(this)); }, resetValue: function () { this.setState({ _value: this.state._pristineValue, _isPristine: true }, function () { this.props._validate(this); }); }, getValue: function () { return this.state._value; }, hasValue: function () { return this.state._value !== ''; }, getErrorMessage: function () { return !this.isValid() || this.showRequired() ? this.state._validationError : null; }, isFormDisabled: function () { return this.props._isFormDisabled(); }, isValid: function () { return this.state._isValid; }, isPristine: function () { return this.state._isPristine; }, isRequired: function () { return !!this.props.required; }, showRequired: function () { return this.state._isRequired; }, showError: function () { return !this.showRequired() && !this.isValid(); }, isValidValue: function (value) { return this.props._isValidValue.call(null, this, value); } }; },{}],3:[function(require,module,exports){ module.exports = { arraysDiffer: function (arrayA, arrayB) { var isDifferent = false; if (arrayA.length !== arrayB.length) { isDifferent = true; } else { arrayA.forEach(function (item, index) { if (item !== arrayB[index]) { isDifferent = true; } }); } return isDifferent; } }; },{}],4:[function(require,module,exports){ module.exports = { 'isDefaultRequiredValue': function (values, value) { return value === undefined || value === ''; }, 'hasValue': function (values, value) { return value !== undefined; }, 'matchRegexp': function (values, value, regexp) { return value !== undefined && !!value.match(regexp); }, 'isUndefined': function (values, value) { return value === undefined; }, 'isEmptyString': function (values, value) { return value === ''; }, 'isEmail': function (values, value) { return value !== undefined && value.match(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i); }, 'isTrue': function (values, value) { return value === true; }, 'isFalse': function (values, value) { return value === false; }, 'isNumeric': function (values, value) { if (typeof value === 'number') { return true; } else { var matchResults = value !== undefined && value.match(/[-+]?(\d*[.])?\d+/); if (!!matchResults) { return matchResults[0] == value; } else { return false; } } }, 'isAlpha': function (values, value) { return value !== undefined && value.match(/^[a-zA-Z]+$/); }, 'isWords': function (values, value) { return value !== undefined && value.match(/^[a-zA-Z\s]+$/); }, 'isSpecialWords': function (values, value) { return value !== undefined && value.match(/^[a-zA-Z\s\u00C0-\u017F]+$/); }, isLength: function (values, value, length) { return value !== undefined && value.length === length; }, equals: function (values, value, eql) { return value == eql; }, equalsField: function (values, value, field) { return value == values[field]; }, maxLength: function (values, value, length) { return value !== undefined && value.length <= length; }, minLength: function (values, value, length) { return value !== undefined && value.length >= length; } }; },{}]},{},[1]);