diff --git a/Gulpfile.js b/Gulpfile.js deleted file mode 100644 index bb955bb4..00000000 --- a/Gulpfile.js +++ /dev/null @@ -1,128 +0,0 @@ -var gulp = require('gulp'); -var source = require('vinyl-source-stream'); // Used to stream bundle for further handling -var browserify = require('browserify'); -var watchify = require('watchify'); -var reactify = require('reactify'); -var gulpif = require('gulp-if'); -var uglify = require('gulp-uglify'); -var streamify = require('gulp-streamify'); -var notify = require('gulp-notify'); -var gutil = require('gulp-util'); -var livereload = require('gulp-livereload'); -var glob = require('glob'); -var fs = require('fs'); - -var dependencies = ['react']; - -var browserifyTask = function (options) { - - // Our app bundler - var appBundler = browserify({ - entries: [options.src], - transform: [reactify], - debug: options.development, - cache: {}, - packageCache: {}, - fullPaths: options.development - }); - - appBundler.external(dependencies); - - // The rebundle process - var rebundle = function () { - var start = Date.now(); - var fileName = options.uglify ? 'formsy-react.min.js' : 'formsy-react.js'; - console.log('Building APP bundle'); - appBundler.bundle() - .on('error', gutil.log) - .pipe(source(fileName)) - .pipe(gulpif(options.uglify, streamify(uglify()))) - .pipe(gulp.dest(options.dest)) - .pipe(notify(function () { - console.log('APP bundle built in ' + (Date.now() - start) + 'ms'); - - /* - // Fix for requirejs - var fs = require('fs'); - var file = fs.readFileSync(options.dest + '/' + fileName).toString(); - file = file.replace('define([],e)', 'define(["react"],e)'); - fs.writeFileSync(options.dest + '/' + fileName, file); - */ - })); - }; - - // Fire up Watchify when developing - if (options.development) { - appBundler = watchify(appBundler); - appBundler.on('update', rebundle); - } - - rebundle(); - - // We create a separate bundle for our dependencies as they - // should not rebundle on file changes. This only happens when - // we develop. When deploying the dependencies will be included - // in the application bundle - if (options.development) { - - var testFiles = glob.sync('./specs/**/*-spec.js'); - var testBundler = browserify({ - entries: testFiles, - debug: true, - transform: [reactify], - cache: {}, - packageCache: {}, - fullPaths: true - }); - - testBundler.external(dependencies); - - var rebundleTests = function () { - var start = Date.now(); - console.log('Building TEST bundle'); - testBundler.bundle() - .on('error', gutil.log) - .pipe(source('specs.js')) - .pipe(gulp.dest(options.dest)) - .pipe(livereload()) - .pipe(notify(function () { - console.log('TEST bundle built in ' + (Date.now() - start) + 'ms'); - })); - }; - - testBundler = watchify(testBundler); - testBundler.on('update', rebundleTests); - rebundleTests(); - - } - -} - -// Starts our development workflow -gulp.task('default', function () { - - livereload.listen({ basePath: 'specs' }); - browserifyTask({ - development: true, - src: './src/main.js', - dest: './build' - }); - -}); - -gulp.task('deploy', function () { - - browserifyTask({ - development: false, - src: './src/main.js', - dest: './release' - }); - - browserifyTask({ - development: false, - src: './src/main.js', - dest: './release', - uglify: true - }); - -}); diff --git a/bower.json b/bower.json index 44ef7d9c..18a8e116 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "formsy-react", - "version": "0.13.1", + "version": "0.14.0", "description": "A form input builder and validator for React JS", "repository": { "type": "git", diff --git a/package.json b/package.json index 0c1e767d..1071fba6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "formsy-react", - "version": "0.13.1", + "version": "0.14.0", "description": "A form input builder and validator for React JS", "repository": { "type": "git", diff --git a/release/formsy-react.js b/release/formsy-react.js index 15645c22..3e4a125b 100644 --- a/release/formsy-react.js +++ b/release/formsy-react.js @@ -1,2 +1,2 @@ -!function(t,i){"object"==typeof exports&&"object"==typeof module?module.exports=i(require("react")):"function"==typeof define&&define.amd?define(["react"],i):"object"==typeof exports?exports.Formsy=i(require("react")):t.Formsy=i(t.react)}(this,function(t){return function(t){function i(r){if(e[r])return e[r].exports;var n=e[r]={exports:{},id:r,loaded:!1};return t[r].call(n.exports,n,n.exports,i),n.loaded=!0,n.exports}var e={};return i.m=t,i.c=e,i.p="",i(0)}([function(t,i,e){(function(i){"use strict";var r=i.React||e(4),n={},s=e(3),o=e(1),u=e(2),a={};n.Mixin=u,n.defaults=function(t){a=t},n.addValidationRule=function(t,i){s[t]=i},n.Form=r.createClass({displayName:"Form",getInitialState:function(){return{isValid:!0,isSubmitting:!1,canChange:!1}},getDefaultProps:function(){return{onSuccess:function(){},onError:function(){},onSubmit:function(){},onValidSubmit:function(){},onInvalidSubmit:function(){},onSubmitted:function(){},onValid:function(){},onInvalid:function(){},onChange:function(){},validationErrors:null}},componentWillMount:function(){this.inputs={},this.model={}},componentDidMount:function(){this.validateForm()},componentWillUpdate:function(){this.prevInputKeys=Object.keys(this.inputs)},componentDidUpdate:function(){this.props.validationErrors&&this.setInputValidationErrors(this.props.validationErrors);var t=Object.keys(this.inputs);o.arraysDiffer(this.prevInputKeys,t)&&this.validateForm()},reset:function(){this.setFormPristine(!0),this.resetModel()},submit:function(t){t&&t.preventDefault(),this.setFormPristine(!1),this.updateModel();var i=this.mapModel();this.props.onSubmit(i,this.resetModel,this.updateInputsWithError),this.state.isValid?this.props.onValidSubmit(i,this.resetModel,this.updateInputsWithError):this.props.onInvalidSubmit(i,this.resetModel,this.updateInputsWithError)},mapModel:function(){return this.props.mapping?this.props.mapping(this.model):this.model},updateModel:function(){Object.keys(this.inputs).forEach(function(t){var i=this.inputs[t];this.model[t]=i.state._value}.bind(this))},resetModel:function(){Object.keys(this.inputs).forEach(function(t){this.inputs[t].resetValue()}.bind(this)),this.validateForm()},setInputValidationErrors:function(t){Object.keys(this.inputs).forEach(function(i,e){var r=this.inputs[i],n=[{_isValid:!(i in t),_validationError:t[i]}];r.setState.apply(r,n)}.bind(this))},updateInputsWithError:function(t){Object.keys(t).forEach(function(i,e){var r=this.inputs[i];if(!r)throw new Error("You are trying to update an input that does not exists. Verify errors object with input names. "+JSON.stringify(t));var n=[{_isValid:!1,_externalError:t[i]}];r.setState.apply(r,n)}.bind(this))},traverseChildrenAndRegisterInputs:function(t){return"object"!=typeof t||null===t?t:r.Children.map(t,function(t){return"object"!=typeof t||null===t?t:t.props&&t.props.name?r.cloneElement(t,{_attachToForm:this.attachToForm,_detachFromForm:this.detachFromForm,_validate:this.validate,_isFormDisabled:this.isFormDisabled,_isValidValue:function(t,i){return this.runValidation(t,i).isValid}.bind(this)},t.props&&t.props.children):r.cloneElement(t,{},this.traverseChildrenAndRegisterInputs(t.props&&t.props.children))},this)},isFormDisabled:function(){return this.props.disabled},getCurrentValues:function(){return Object.keys(this.inputs).reduce(function(t,i){var e=this.inputs[i];return t[i]=e.state._value,t}.bind(this),{})},setFormPristine:function(t){var i=this.inputs,e=Object.keys(i);this.setState({_formSubmitted:!t}),e.forEach(function(e,r){var n=i[e];n.setState({_formSubmitted:!t,_isPristine:t})}.bind(this))},validate:function(t){this.state.canChange&&this.props.onChange(this.getCurrentValues());var i=this.runValidation(t);t.setState({_isValid:i.isValid,_isRequired:i.isRequired,_validationError:i.error,_externalError:null},this.validateForm)},runValidation:function(t,i){var e=this.getCurrentValues(),r=t.props.validationErrors,n=t.props.validationError;i=2===arguments.length?i:t.state._value;var s=this.runRules(i,e,t._validations),o=this.runRules(i,e,t._requiredValidations);"function"==typeof t.validate&&(s.failed=t.validate()?[]:["failed"]);var u=Object.keys(t._requiredValidations).length?!!o.success.length:!1,a=!(s.failed.length||this.props.validationErrors&&this.props.validationErrors[t.props.name]);return{isRequired:u,isValid:u?!1:a,error:function(){return a&&!u?"":s.errors.length?s.errors[0]:this.props.validationErrors&&this.props.validationErrors[t.props.name]?this.props.validationErrors[t.props.name]:u?r[o.success[0]]||null:a?void 0:r[s.failed[0]]||n}.call(this)}},runRules:function(t,i,e){var r={errors:[],failed:[],success:[]};return Object.keys(e).length&&Object.keys(e).forEach(function(n){if(s[n]&&"function"==typeof e[n])throw new Error("Formsy does not allow you to override default validations: "+n);if(!s[n]&&"function"!=typeof e[n])throw new Error("Formsy does not have the validation rule: "+n);if("function"==typeof e[n]){var o=e[n](i,t);return void("string"==typeof o?(r.errors.push(o),r.failed.push(n)):o||r.failed.push(n))}if("function"!=typeof e[n]){var o=s[n](i,t,e[n]);return void("string"==typeof o?(r.errors.push(o),r.failed.push(n)):o?r.success.push(n):r.failed.push(n))}return r.success.push(n)}),r},validateForm:function(){var t=!0,i=this.inputs,e=Object.keys(i),r=function(){e.forEach(function(e){i[e].state._isValid||(t=!1)}.bind(this)),this.setState({isValid:t}),t?this.props.onValid():this.props.onInvalid(),this.setState({canChange:!0})}.bind(this);e.forEach(function(t,n){var s=i[t],o=this.runValidation(s);o.isValid&&s.state._externalError&&(o.isValid=!1),s.setState({_isValid:o.isValid,_isRequired:o.isRequired,_validationError:o.error,_externalError:!o.isValid&&s.state._externalError?s.state._externalError:null},n===e.length-1?r:null)}.bind(this)),!e.length&&this.isMounted()&&this.setState({canChange:!0})},attachToForm:function(t){this.inputs[t.props.name]=t,this.model[t.props.name]=t.state._value,this.validate(t)},detachFromForm:function(t){delete this.inputs[t.props.name],delete this.model[t.props.name]},render:function(){return r.DOM.form({onSubmit:this.submit,className:this.props.className},this.traverseChildrenAndRegisterInputs(this.props.children))}}),i.exports||i.module||i.define&&i.define.amd||(i.Formsy=n),t.exports=n}).call(i,function(){return this}())},function(t,i,e){"use strict";t.exports={arraysDiffer:function(t,i){var e=!1;return t.length!==i.length?e=!0:t.forEach(function(t,r){this.isSame(t,i[r])||(e=!0)},this),e},objectsDiffer:function(t,i){var e=!1;return Object.keys(t).length!==Object.keys(i).length?e=!0:Object.keys(t).forEach(function(r){this.isSame(t[r],i[r])||(e=!0)},this),e},isSame:function(t,i){return Array.isArray(t)?!this.arraysDiffer(t,i):"object"==typeof t&&null!==t?!this.objectsDiffer(t,i):t===i}}},function(t,i,e){"use strict";var r=e(1),n=function(t){return"string"==typeof t?t.split(/\,(?![^{\[]*[}\]])/g).reduce(function(t,i){var e=i.split(":"),r=e.shift();if(e=e.map(function(t){try{return JSON.parse(t)}catch(i){return t}}),e.length>1)throw new Error("Formsy does not support multiple args on string validations. Use object format of validations instead.");return t[r]=e.length?e[0]:!0,t},{}):t||{}};t.exports={getInitialState:function(){return{_value:this.props.value,_isRequired:!1,_isValid:!0,_isPristine:!0,_pristineValue:this.props.value,_validationError:"",_externalError:null,_formSubmitted:!1}},getDefaultProps:function(){return{validationError:"",validationErrors:{}}},componentWillMount:function(){var t=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");return this.props._attachToForm?void t():setTimeout(function(){if(this.isMounted()){if(!this.props._attachToForm)throw new Error("Form Mixin requires component to be nested in a Form");t()}}.bind(this),0)},componentWillReceiveProps:function(t){this.setValidations(t.validations,t.required)},componentDidUpdate:function(t){r.isSame(this.props.value,t.value)||this.setValue(this.props.value)},componentWillUnmount:function(){this.props._detachFromForm(this)},setValidations:function(t,i){this._validations=n(t)||{},this._requiredValidations=i===!0?{isDefaultRequiredValue:!0}:n(i)},setValue:function(t){this.setState({_value:t,_isPristine:!1},function(){this.props._validate(this)}.bind(this))},resetValue:function(){this.setState({_value:this.state._pristineValue,_isPristine:!0},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._externalError||this.state._validationError:null},isFormDisabled:function(){return this.props._isFormDisabled()},isValid:function(){return this.state._isValid},isPristine:function(){return this.state._isPristine},isFormSubmitted:function(){return this.state._formSubmitted},isRequired:function(){return!!this.props.required},showRequired:function(){return this.state._isRequired},showError:function(){return!this.showRequired()&&!this.isValid()},isValidValue:function(t){return this.props._isValidValue.call(null,this,t)}}},function(t,i,e){"use strict";var r=function(t){return null!==t&&void 0!==t},n={isDefaultRequiredValue:function(t,i){return void 0===i||""===i},hasValue:function(t,i){return!!i},matchRegexp:function(t,i,e){return r(i)&&e.test(i)},isUndefined:function(t,i){return void 0===i},isEmptyString:function(t,i){return""===i},isEmail:function(t,i){return n.matchRegexp(t,i,/^((([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(t,i){return i===!0},isFalse:function(t,i){return i===!1},isNumeric:function(t,i){if(!r(i))return!1;if("number"==typeof i)return!0;var e=i.match(/[-+]?(\d*[.])?\d+/);return e?e[0]==i:!1},isAlpha:function(t,i){return i&&/^[a-zA-Z]+$/.test(i)},isWords:function(t,i){return i&&/^[a-zA-Z\s]+$/.test(i)},isSpecialWords:function(t,i){return!i||/^[a-zA-Z\s\u00C0-\u017F]+$/.test(i)},isLength:function(t,i,e){return r(i)&&i.length===e},equals:function(t,i,e){return i==e},equalsField:function(t,i,e){return i==t[e]},maxLength:function(t,i,e){return r(i)&&i.length<=e},minLength:function(t,i,e){return r(i)&&i.length>=e}};t.exports=n},function(i,e,r){i.exports=t}])}); +!function(t,i){"object"==typeof exports&&"object"==typeof module?module.exports=i(require("react")):"function"==typeof define&&define.amd?define(["react"],i):"object"==typeof exports?exports.Formsy=i(require("react")):t.Formsy=i(t.react)}(this,function(t){return function(t){function i(r){if(e[r])return e[r].exports;var n=e[r]={exports:{},id:r,loaded:!1};return t[r].call(n.exports,n,n.exports,i),n.loaded=!0,n.exports}var e={};return i.m=t,i.c=e,i.p="",i(0)}([function(t,i,e){(function(i){"use strict";var r=i.React||e(4),n={},s=e(3),u=e(1),o=e(2),a={};n.Mixin=o,n.defaults=function(t){a=t},n.addValidationRule=function(t,i){s[t]=i},n.Form=r.createClass({displayName:"Form",getInitialState:function(){return{isValid:!0,isSubmitting:!1,canChange:!1}},getDefaultProps:function(){return{onSuccess:function(){},onError:function(){},onSubmit:function(){},onValidSubmit:function(){},onInvalidSubmit:function(){},onSubmitted:function(){},onValid:function(){},onInvalid:function(){},onChange:function(){},validationErrors:null,preventExternalInvalidation:!1}},componentWillMount:function(){this.inputs={},this.model={}},componentDidMount:function(){this.validateForm()},componentWillUpdate:function(){this.prevInputKeys=Object.keys(this.inputs)},componentDidUpdate:function(){this.props.validationErrors&&this.setInputValidationErrors(this.props.validationErrors);var t=Object.keys(this.inputs);u.arraysDiffer(this.prevInputKeys,t)&&this.validateForm()},reset:function(t){this.setFormPristine(!0),this.resetModel(t)},submit:function(t){t&&t.preventDefault(),this.setFormPristine(!1),this.updateModel();var i=this.mapModel();this.props.onSubmit(i,this.resetModel,this.updateInputsWithError),this.state.isValid?this.props.onValidSubmit(i,this.resetModel,this.updateInputsWithError):this.props.onInvalidSubmit(i,this.resetModel,this.updateInputsWithError)},mapModel:function(){return this.props.mapping?this.props.mapping(this.model):Object.keys(this.model).reduce(function(t,i){for(var e=i.split(".");e.length;){var r=e.shift();t[r]=e.length?t[r]||{}:this.model[i]}return t}.bind(this),{})},updateModel:function(){Object.keys(this.inputs).forEach(function(t){var i=this.inputs[t];this.model[t]=i.state._value}.bind(this))},resetModel:function(t){Object.keys(this.inputs).forEach(function(i){t&&t[i]?this.inputs[i].setValue(t[i]):this.inputs[i].resetValue()}.bind(this)),this.validateForm()},setInputValidationErrors:function(t){Object.keys(this.inputs).forEach(function(i,e){var r=this.inputs[i],n=[{_isValid:!(i in t),_validationError:t[i]}];r.setState.apply(r,n)}.bind(this))},isChanged:function(){return!u.isSame(this.getPristineValues(),this.getCurrentValues())},getPristineValues:function(){var t=this.inputs;return Object.keys(t).reduce(function(i,e){var r=t[e];return i[e]=r.props.value,i},{})},updateInputsWithError:function(t){Object.keys(t).forEach(function(i,e){var r=this.inputs[i];if(!r)throw new Error("You are trying to update an input that does not exist. Verify errors object with input names. "+JSON.stringify(t));var n=[{_isValid:this.props.preventExternalInvalidation||!1,_externalError:t[i]}];r.setState.apply(r,n)}.bind(this))},traverseChildrenAndRegisterInputs:function(t){return"object"!=typeof t||null===t?t:r.Children.map(t,function(t){return"object"!=typeof t||null===t?t:t.props&&t.props.name?r.cloneElement(t,{_attachToForm:this.attachToForm,_detachFromForm:this.detachFromForm,_validate:this.validate,_isFormDisabled:this.isFormDisabled,_isValidValue:function(t,i){return this.runValidation(t,i).isValid}.bind(this)},t.props&&t.props.children):r.cloneElement(t,{},this.traverseChildrenAndRegisterInputs(t.props&&t.props.children))},this)},isFormDisabled:function(){return this.props.disabled},getCurrentValues:function(){return Object.keys(this.inputs).reduce(function(t,i){var e=this.inputs[i];return t[i]=e.state._value,t}.bind(this),{})},setFormPristine:function(t){var i=this.inputs,e=Object.keys(i);this.setState({_formSubmitted:!t}),e.forEach(function(e,r){var n=i[e];n.setState({_formSubmitted:!t,_isPristine:t})}.bind(this))},validate:function(t){this.state.canChange&&this.props.onChange(this.getCurrentValues(),this.isChanged());var i=this.runValidation(t);t.setState({_isValid:i.isValid,_isRequired:i.isRequired,_validationError:i.error,_externalError:null},this.validateForm)},runValidation:function(t,i){var e=this.getCurrentValues(),r=t.props.validationErrors,n=t.props.validationError;i=2===arguments.length?i:t.state._value;var s=this.runRules(i,e,t._validations),u=this.runRules(i,e,t._requiredValidations);"function"==typeof t.validate&&(s.failed=t.validate()?[]:["failed"]);var o=Object.keys(t._requiredValidations).length?!!u.success.length:!1,a=!(s.failed.length||this.props.validationErrors&&this.props.validationErrors[t.props.name]);return{isRequired:o,isValid:o?!1:a,error:function(){return a&&!o?"":s.errors.length?s.errors[0]:this.props.validationErrors&&this.props.validationErrors[t.props.name]?this.props.validationErrors[t.props.name]:o?r[u.success[0]]||null:a?void 0:r[s.failed[0]]||n}.call(this)}},runRules:function(t,i,e){var r={errors:[],failed:[],success:[]};return Object.keys(e).length&&Object.keys(e).forEach(function(n){if(s[n]&&"function"==typeof e[n])throw new Error("Formsy does not allow you to override default validations: "+n);if(!s[n]&&"function"!=typeof e[n])throw new Error("Formsy does not have the validation rule: "+n);if("function"==typeof e[n]){var u=e[n](i,t);return void("string"==typeof u?(r.errors.push(u),r.failed.push(n)):u||r.failed.push(n))}if("function"!=typeof e[n]){var u=s[n](i,t,e[n]);return void("string"==typeof u?(r.errors.push(u),r.failed.push(n)):u?r.success.push(n):r.failed.push(n))}return r.success.push(n)}),r},validateForm:function(){var t=!0,i=this.inputs,e=Object.keys(i),r=function(){e.forEach(function(e){i[e].state._isValid||(t=!1)}.bind(this)),this.setState({isValid:t}),t?this.props.onValid():this.props.onInvalid(),this.setState({canChange:!0})}.bind(this);e.forEach(function(t,n){var s=i[t],u=this.runValidation(s);u.isValid&&s.state._externalError&&(u.isValid=!1),s.setState({_isValid:u.isValid,_isRequired:u.isRequired,_validationError:u.error,_externalError:!u.isValid&&s.state._externalError?s.state._externalError:null},n===e.length-1?r:null)}.bind(this)),!e.length&&this.isMounted()&&this.setState({canChange:!0})},attachToForm:function(t){this.inputs[t.props.name]=t,this.model[t.props.name]=t.state._value,this.validate(t)},detachFromForm:function(t){delete this.inputs[t.props.name],delete this.model[t.props.name]},render:function(){return r.DOM.form(u.extend({},this.props,{onSubmit:this.submit,className:this.props.className}),this.traverseChildrenAndRegisterInputs(this.props.children))}}),i.exports||i.module||i.define&&i.define.amd||(i.Formsy=n),t.exports=n}).call(i,function(){return this}())},function(t,i,e){"use strict";t.exports={arraysDiffer:function(t,i){var e=!1;return t.length!==i.length?e=!0:t.forEach(function(t,r){this.isSame(t,i[r])||(e=!0)},this),e},objectsDiffer:function(t,i){var e=!1;return Object.keys(t).length!==Object.keys(i).length?e=!0:Object.keys(t).forEach(function(r){this.isSame(t[r],i[r])||(e=!0)},this),e},isSame:function(t,i){return typeof t!=typeof i?!1:Array.isArray(t)?!this.arraysDiffer(t,i):"object"==typeof t&&null!==t&&null!==i?!this.objectsDiffer(t,i):t===i},extend:function(){var t=[].slice.call(arguments),i=t.shift();return t.reduce(function(t,i){return Object.keys(i).reduce(function(t,e){return t[e]=i[e],t},t)},i)}}},function(t,i,e){"use strict";var r=e(1),n=function(t){return"string"==typeof t?t.split(/\,(?![^{\[]*[}\]])/g).reduce(function(t,i){var e=i.split(":"),r=e.shift();if(e=e.map(function(t){try{return JSON.parse(t)}catch(i){return t}}),e.length>1)throw new Error("Formsy does not support multiple args on string validations. Use object format of validations instead.");return t[r]=e.length?e[0]:!0,t},{}):t||{}};t.exports={getInitialState:function(){return{_value:this.props.value,_isRequired:!1,_isValid:!0,_isPristine:!0,_pristineValue:this.props.value,_validationError:"",_externalError:null,_formSubmitted:!1}},getDefaultProps:function(){return{validationError:"",validationErrors:{}}},componentWillMount:function(){var t=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");return this.props._attachToForm?void t():setTimeout(function(){if(this.isMounted()){if(!this.props._attachToForm)throw new Error("Form Mixin requires component to be nested in a Form");t()}}.bind(this),0)},componentWillReceiveProps:function(t){this.setValidations(t.validations,t.required)},componentDidUpdate:function(t){r.isSame(this.props.value,t.value)||this.setValue(this.props.value)},componentWillUnmount:function(){this.props._detachFromForm(this)},setValidations:function(t,i){this._validations=n(t)||{},this._requiredValidations=i===!0?{isDefaultRequiredValue:!0}:n(i)},setValue:function(t){this.setState({_value:t,_isPristine:!1},function(){this.props._validate(this)}.bind(this))},resetValue:function(){this.setState({_value:this.state._pristineValue,_isPristine:!0},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._externalError||this.state._validationError:null},isFormDisabled:function(){return this.props._isFormDisabled()},isValid:function(){return this.state._isValid},isPristine:function(){return this.state._isPristine},isFormSubmitted:function(){return this.state._formSubmitted},isRequired:function(){return!!this.props.required},showRequired:function(){return this.state._isRequired},showError:function(){return!this.showRequired()&&!this.isValid()},isValidValue:function(t){return this.props._isValidValue.call(null,this,t)}}},function(t,i,e){"use strict";var r=function(t){return null!==t&&void 0!==t},n={isDefaultRequiredValue:function(t,i){return void 0===i||""===i},isExisty:function(t){function i(i,e){return t.apply(this,arguments)}return i.toString=function(){return t.toString()},i}(function(t,i){return r(i)}),matchRegexp:function(t,i,e){return r(i)&&e.test(i)},isUndefined:function(t,i){return void 0===i},isEmptyString:function(t,i){return""===i},isEmail:function(t,i){return n.matchRegexp(t,i,/^((([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)},isUrl:function(t,i){return n.matchRegexp(t,i,/^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([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])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i)},isTrue:function(t,i){return i===!0},isFalse:function(t,i){return i===!1},isNumeric:function(t,i){if(!r(i))return!1;if("number"==typeof i)return!0;var e=i.match(/[-+]?(\d*[.])?\d+/);return e?e[0]==i:!1},isAlpha:function(t,i){return i&&/^[a-zA-Z]+$/.test(i)},isWords:function(t,i){return i&&/^[a-zA-Z\s]+$/.test(i)},isSpecialWords:function(t,i){return!i||/^[a-zA-Z\s\u00C0-\u017F]+$/.test(i)},isLength:function(t,i,e){return r(i)&&i.length===e},equals:function(t,i,e){return i==e},equalsField:function(t,i,e){return i==t[e]},maxLength:function(t,i,e){return r(i)&&i.length<=e},minLength:function(t,i,e){return r(i)&&i.length>=e}};t.exports=n},function(i,e,r){i.exports=t}])}); //# sourceMappingURL=formsy-react.js.map \ No newline at end of file diff --git a/release/formsy-react.js.map b/release/formsy-react.js.map index 96609476..528710c3 100644 --- a/release/formsy-react.js.map +++ b/release/formsy-react.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///formsy-react.js","webpack:///webpack/bootstrap 70c91fb7cdf635a539c0","webpack:///./src/main.js","webpack:///./src/utils.js","webpack:///./src/Mixin.js","webpack:///./src/validationRules.js","webpack:///external \"react\""],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_4__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","global","React","Formsy","validationRules","utils","Mixin","options","defaults","passedOptions","addValidationRule","name","func","Form","createClass","displayName","getInitialState","isValid","isSubmitting","canChange","getDefaultProps","onSuccess","onError","onSubmit","onValidSubmit","onInvalidSubmit","onSubmitted","onValid","onInvalid","onChange","validationErrors","componentWillMount","inputs","model","componentDidMount","validateForm","componentWillUpdate","prevInputKeys","Object","keys","componentDidUpdate","props","setInputValidationErrors","newInputKeys","arraysDiffer","reset","setFormPristine","resetModel","submit","event","preventDefault","updateModel","mapModel","updateInputsWithError","state","mapping","forEach","component","_value","bind","resetValue","errors","index","args","_isValid","_validationError","setState","apply","Error","JSON","stringify","_externalError","traverseChildrenAndRegisterInputs","children","Children","map","child","cloneElement","_attachToForm","attachToForm","_detachFromForm","detachFromForm","_validate","validate","_isFormDisabled","isFormDisabled","_isValidValue","value","runValidation","disabled","getCurrentValues","reduce","data","isPristine","inputKeys","_formSubmitted","_isPristine","validation","_isRequired","isRequired","error","currentValues","validationError","arguments","length","validationResults","runRules","_validations","requiredResults","_requiredValidations","failed","success","validations","results","validationMethod","push","allIsValid","onValidationComplete","isMounted","render","DOM","form","className","a","b","isDifferent","item","isSame","objectsDiffer","key","Array","isArray","convertValidationsToObject","split","validateMethod","shift","arg","parse","e","_pristineValue","configure","setValidations","required","setTimeout","componentWillReceiveProps","nextProps","prevProps","setValue","componentWillUnmount","isDefaultRequiredValue","getValue","hasValue","getErrorMessage","showRequired","isFormSubmitted","showError","isValidValue","isExisty","undefined","values","matchRegexp","regexp","test","isUndefined","isEmptyString","isEmail","isTrue","isFalse","isNumeric","matchResults","match","isAlpha","isWords","isSpecialWords","isLength","equals","eql","equalsField","field","maxLength","minLength"],"mappings":"CAAA,SAAA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boF,QAAS,SAAUZ,EAAQxE,GACzB,MAAOA,IAAS,cAAc2E,KAAK3E,IAErCqF,QAAS,SAAUb,EAAQxE,GACzB,MAAOA,IAAS,gBAAgB2E,KAAK3E,IAEvCsF,eAAgB,SAAUd,EAAQxE,GAChC,OAAQA,GAAS,6BAA6B2E,KAAK3E,IAErDuF,SAAU,SAAUf,EAAQxE,EAAOiB,GACjC,MAAOqD,GAAStE,IAAUA,EAAMiB,SAAWA,GAE7CuE,OAAQ,SAAUhB,EAAQxE,EAAOyF,GAC/B,MAAOzF,IAASyF,GAElBC,YAAa,SAAUlB,EAAQxE,EAAO2F,GACpC,MAAO3F,IAASwE,EAAOmB,IAEzBC,UAAW,SAAUpB,EAAQxE,EAAOiB,GAClC,MAAOqD,GAAStE,IAAUA,EAAMiB,QAAUA,GAE5C4E,UAAW,SAAUrB,EAAQxE,EAAOiB,GAClC,MAAOqD,GAAStE,IAAUA,EAAMiB,QAAUA,GAI9CvH,GAAOD,QAAUgI,GLoqBX,SAAS/H,EAAQD,EAASQ,GM1uBhCP,EAAAD,QAAAM","file":"formsy-react.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"react\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Formsy\"] = factory(require(\"react\"));\n\telse\n\t\troot[\"Formsy\"] = factory(root[\"react\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_4__) {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\n **/","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"react\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Formsy\"] = factory(require(\"react\"));\n\telse\n\t\troot[\"Formsy\"] = factory(root[\"react\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_4__) {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t/* WEBPACK VAR INJECTION */(function(global) {'use strict';\n\t\n\tvar React = global.React || __webpack_require__(4);\n\tvar Formsy = {};\n\tvar validationRules = __webpack_require__(3);\n\tvar utils = __webpack_require__(1);\n\tvar Mixin = __webpack_require__(2);\n\tvar options = {};\n\t\n\tFormsy.Mixin = Mixin;\n\t\n\tFormsy.defaults = function (passedOptions) {\n\t options = passedOptions;\n\t};\n\t\n\tFormsy.addValidationRule = function (name, func) {\n\t validationRules[name] = func;\n\t};\n\t\n\tFormsy.Form = React.createClass({\n\t displayName: 'Form',\n\t\n\t getInitialState: function getInitialState() {\n\t return {\n\t isValid: true,\n\t isSubmitting: false,\n\t canChange: false\n\t };\n\t },\n\t getDefaultProps: function getDefaultProps() {\n\t return {\n\t onSuccess: function onSuccess() {},\n\t onError: function onError() {},\n\t onSubmit: function onSubmit() {},\n\t onValidSubmit: function onValidSubmit() {},\n\t onInvalidSubmit: function onInvalidSubmit() {},\n\t onSubmitted: function onSubmitted() {},\n\t onValid: function onValid() {},\n\t onInvalid: function onInvalid() {},\n\t onChange: function onChange() {},\n\t validationErrors: null\n\t };\n\t },\n\t\n\t // Add a map to store the inputs of the form, a model to store\n\t // the values of the form and register child inputs\n\t componentWillMount: function componentWillMount() {\n\t this.inputs = {};\n\t this.model = {};\n\t },\n\t\n\t componentDidMount: function componentDidMount() {\n\t this.validateForm();\n\t },\n\t\n\t componentWillUpdate: function componentWillUpdate() {\n\t\n\t // Keep a reference to input keys before form updates,\n\t // to check if inputs has changed after render\n\t this.prevInputKeys = Object.keys(this.inputs);\n\t },\n\t\n\t componentDidUpdate: function componentDidUpdate() {\n\t\n\t if (this.props.validationErrors) {\n\t this.setInputValidationErrors(this.props.validationErrors);\n\t }\n\t\n\t var newInputKeys = Object.keys(this.inputs);\n\t if (utils.arraysDiffer(this.prevInputKeys, newInputKeys)) {\n\t this.validateForm();\n\t }\n\t },\n\t\n\t reset: function reset() {\n\t this.setFormPristine(true);\n\t this.resetModel();\n\t },\n\t\n\t // Update model, submit to url prop and send the model\n\t submit: function submit(event) {\n\t\n\t event && event.preventDefault();\n\t\n\t // Trigger form as not pristine.\n\t // If any inputs have not been touched yet this will make them dirty\n\t // so validation becomes visible (if based on isPristine)\n\t this.setFormPristine(false);\n\t this.updateModel();\n\t var model = this.mapModel();\n\t this.props.onSubmit(model, this.resetModel, this.updateInputsWithError);\n\t this.state.isValid ? this.props.onValidSubmit(model, this.resetModel, this.updateInputsWithError) : this.props.onInvalidSubmit(model, this.resetModel, this.updateInputsWithError);\n\t },\n\t\n\t mapModel: function mapModel() {\n\t return this.props.mapping ? this.props.mapping(this.model) : this.model;\n\t },\n\t\n\t // Goes through all registered components and\n\t // updates the model values\n\t updateModel: function updateModel() {\n\t Object.keys(this.inputs).forEach((function (name) {\n\t var component = this.inputs[name];\n\t this.model[name] = component.state._value;\n\t }).bind(this));\n\t },\n\t\n\t // Reset each key in the model to the original / initial value\n\t resetModel: function resetModel() {\n\t Object.keys(this.inputs).forEach((function (name) {\n\t this.inputs[name].resetValue();\n\t }).bind(this));\n\t this.validateForm();\n\t },\n\t\n\t setInputValidationErrors: function setInputValidationErrors(errors) {\n\t Object.keys(this.inputs).forEach((function (name, index) {\n\t var component = this.inputs[name];\n\t var args = [{\n\t _isValid: !(name in errors),\n\t _validationError: errors[name]\n\t }];\n\t component.setState.apply(component, args);\n\t }).bind(this));\n\t },\n\t\n\t // Go through errors from server and grab the components\n\t // stored in the inputs map. Change their state to invalid\n\t // and set the serverError message\n\t updateInputsWithError: function updateInputsWithError(errors) {\n\t Object.keys(errors).forEach((function (name, index) {\n\t var component = this.inputs[name];\n\t\n\t if (!component) {\n\t throw new Error('You are trying to update an input that does not exists. Verify errors object with input names. ' + JSON.stringify(errors));\n\t }\n\t\n\t var args = [{\n\t _isValid: false,\n\t _externalError: errors[name]\n\t }];\n\t component.setState.apply(component, args);\n\t }).bind(this));\n\t },\n\t\n\t // Traverse the children and children of children to find\n\t // all inputs by checking the name prop. Maybe do a better\n\t // check here\n\t traverseChildrenAndRegisterInputs: function traverseChildrenAndRegisterInputs(children) {\n\t\n\t if (typeof children !== 'object' || children === null) {\n\t return children;\n\t }\n\t return React.Children.map(children, function (child) {\n\t\n\t if (typeof child !== 'object' || child === null) {\n\t return child;\n\t }\n\t\n\t if (child.props && child.props.name) {\n\t\n\t return React.cloneElement(child, {\n\t _attachToForm: this.attachToForm,\n\t _detachFromForm: this.detachFromForm,\n\t _validate: this.validate,\n\t _isFormDisabled: this.isFormDisabled,\n\t _isValidValue: (function (component, value) {\n\t return this.runValidation(component, value).isValid;\n\t }).bind(this)\n\t }, child.props && child.props.children);\n\t } else {\n\t return React.cloneElement(child, {}, this.traverseChildrenAndRegisterInputs(child.props && child.props.children));\n\t }\n\t }, this);\n\t },\n\t\n\t isFormDisabled: function isFormDisabled() {\n\t return this.props.disabled;\n\t },\n\t\n\t getCurrentValues: function getCurrentValues() {\n\t return Object.keys(this.inputs).reduce((function (data, name) {\n\t var component = this.inputs[name];\n\t data[name] = component.state._value;\n\t return data;\n\t }).bind(this), {});\n\t },\n\t\n\t setFormPristine: function setFormPristine(isPristine) {\n\t var inputs = this.inputs;\n\t var inputKeys = Object.keys(inputs);\n\t\n\t this.setState({\n\t _formSubmitted: !isPristine\n\t });\n\t\n\t // Iterate through each component and set it as pristine\n\t // or \"dirty\".\n\t inputKeys.forEach((function (name, index) {\n\t var component = inputs[name];\n\t component.setState({\n\t _formSubmitted: !isPristine,\n\t _isPristine: isPristine\n\t });\n\t }).bind(this));\n\t },\n\t\n\t // Use the binded values and the actual input value to\n\t // validate the input and set its state. Then check the\n\t // state of the form itself\n\t validate: function validate(component) {\n\t\n\t // Trigger onChange\n\t if (this.state.canChange) {\n\t this.props.onChange(this.getCurrentValues());\n\t }\n\t\n\t var validation = this.runValidation(component);\n\t // Run through the validations, split them up and call\n\t // the validator IF there is a value or it is required\n\t component.setState({\n\t _isValid: validation.isValid,\n\t _isRequired: validation.isRequired,\n\t _validationError: validation.error,\n\t _externalError: null\n\t }, this.validateForm);\n\t },\n\t\n\t // Checks validation on current value or a passed value\n\t runValidation: function runValidation(component, value) {\n\t\n\t var currentValues = this.getCurrentValues();\n\t var validationErrors = component.props.validationErrors;\n\t var validationError = component.props.validationError;\n\t value = arguments.length === 2 ? value : component.state._value;\n\t\n\t var validationResults = this.runRules(value, currentValues, component._validations);\n\t var requiredResults = this.runRules(value, currentValues, component._requiredValidations);\n\t\n\t // the component defines an explicit validate function\n\t if (typeof component.validate === 'function') {\n\t validationResults.failed = component.validate() ? [] : ['failed'];\n\t }\n\t\n\t var isRequired = Object.keys(component._requiredValidations).length ? !!requiredResults.success.length : false;\n\t var isValid = !validationResults.failed.length && !(this.props.validationErrors && this.props.validationErrors[component.props.name]);\n\t\n\t return {\n\t isRequired: isRequired,\n\t isValid: isRequired ? false : isValid,\n\t error: (function () {\n\t\n\t if (isValid && !isRequired) {\n\t return '';\n\t }\n\t\n\t if (validationResults.errors.length) {\n\t return validationResults.errors[0];\n\t }\n\t\n\t if (this.props.validationErrors && this.props.validationErrors[component.props.name]) {\n\t return this.props.validationErrors[component.props.name];\n\t }\n\t\n\t if (isRequired) {\n\t return validationErrors[requiredResults.success[0]] || null;\n\t }\n\t\n\t if (!isValid) {\n\t return validationErrors[validationResults.failed[0]] || validationError;\n\t }\n\t }).call(this)\n\t };\n\t },\n\t\n\t runRules: function runRules(value, currentValues, validations) {\n\t\n\t var results = {\n\t errors: [],\n\t failed: [],\n\t success: []\n\t };\n\t if (Object.keys(validations).length) {\n\t Object.keys(validations).forEach(function (validationMethod) {\n\t\n\t if (validationRules[validationMethod] && typeof validations[validationMethod] === 'function') {\n\t throw new Error('Formsy does not allow you to override default validations: ' + validationMethod);\n\t }\n\t\n\t if (!validationRules[validationMethod] && typeof validations[validationMethod] !== 'function') {\n\t throw new Error('Formsy does not have the validation rule: ' + validationMethod);\n\t }\n\t\n\t if (typeof validations[validationMethod] === 'function') {\n\t var validation = validations[validationMethod](currentValues, value);\n\t if (typeof validation === 'string') {\n\t results.errors.push(validation);\n\t results.failed.push(validationMethod);\n\t } else if (!validation) {\n\t results.failed.push(validationMethod);\n\t }\n\t return;\n\t } else if (typeof validations[validationMethod] !== 'function') {\n\t var validation = validationRules[validationMethod](currentValues, value, validations[validationMethod]);\n\t if (typeof validation === 'string') {\n\t results.errors.push(validation);\n\t results.failed.push(validationMethod);\n\t } else if (!validation) {\n\t results.failed.push(validationMethod);\n\t } else {\n\t results.success.push(validationMethod);\n\t }\n\t return;\n\t }\n\t\n\t return results.success.push(validationMethod);\n\t });\n\t }\n\t\n\t return results;\n\t },\n\t\n\t // Validate the form by going through all child input components\n\t // and check their state\n\t validateForm: function validateForm() {\n\t var allIsValid = true;\n\t var inputs = this.inputs;\n\t var inputKeys = Object.keys(inputs);\n\t\n\t // We need a callback as we are validating all inputs again. This will\n\t // run when the last component has set its state\n\t var onValidationComplete = (function () {\n\t inputKeys.forEach((function (name) {\n\t if (!inputs[name].state._isValid) {\n\t allIsValid = false;\n\t }\n\t }).bind(this));\n\t\n\t this.setState({\n\t isValid: allIsValid\n\t });\n\t\n\t if (allIsValid) {\n\t this.props.onValid();\n\t } else {\n\t this.props.onInvalid();\n\t }\n\t\n\t // Tell the form that it can start to trigger change events\n\t this.setState({\n\t canChange: true\n\t });\n\t }).bind(this);\n\t\n\t // Run validation again in case affected by other inputs. The\n\t // last component validated will run the onValidationComplete callback\n\t inputKeys.forEach((function (name, index) {\n\t var component = inputs[name];\n\t var validation = this.runValidation(component);\n\t if (validation.isValid && component.state._externalError) {\n\t validation.isValid = false;\n\t }\n\t component.setState({\n\t _isValid: validation.isValid,\n\t _isRequired: validation.isRequired,\n\t _validationError: validation.error,\n\t _externalError: !validation.isValid && component.state._externalError ? component.state._externalError : null\n\t }, index === inputKeys.length - 1 ? onValidationComplete : null);\n\t }).bind(this));\n\t\n\t // If there are no inputs, set state where form is ready to trigger\n\t // change event. New inputs might be added later\n\t if (!inputKeys.length && this.isMounted()) {\n\t this.setState({\n\t canChange: true\n\t });\n\t }\n\t },\n\t\n\t // Method put on each input component to register\n\t // itself to the form\n\t attachToForm: function attachToForm(component) {\n\t this.inputs[component.props.name] = component;\n\t this.model[component.props.name] = component.state._value;\n\t this.validate(component);\n\t },\n\t\n\t // Method put on each input component to unregister\n\t // itself from the form\n\t detachFromForm: function detachFromForm(component) {\n\t delete this.inputs[component.props.name];\n\t delete this.model[component.props.name];\n\t },\n\t render: function render() {\n\t\n\t return React.DOM.form({\n\t onSubmit: this.submit,\n\t className: this.props.className\n\t }, this.traverseChildrenAndRegisterInputs(this.props.children));\n\t }\n\t});\n\t\n\tif (!global.exports && !global.module && (!global.define || !global.define.amd)) {\n\t global.Formsy = Formsy;\n\t}\n\t\n\tmodule.exports = Formsy;\n\t/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))\n\n/***/ },\n/* 1 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tmodule.exports = {\n\t arraysDiffer: function arraysDiffer(a, b) {\n\t var isDifferent = false;\n\t if (a.length !== b.length) {\n\t isDifferent = true;\n\t } else {\n\t a.forEach(function (item, index) {\n\t if (!this.isSame(item, b[index])) {\n\t isDifferent = true;\n\t }\n\t }, this);\n\t }\n\t return isDifferent;\n\t },\n\t objectsDiffer: function objectsDiffer(a, b) {\n\t var isDifferent = false;\n\t if (Object.keys(a).length !== Object.keys(b).length) {\n\t isDifferent = true;\n\t } else {\n\t Object.keys(a).forEach(function (key) {\n\t if (!this.isSame(a[key], b[key])) {\n\t isDifferent = true;\n\t }\n\t }, this);\n\t }\n\t return isDifferent;\n\t },\n\t isSame: function isSame(a, b) {\n\t\n\t if (Array.isArray(a)) {\n\t return !this.arraysDiffer(a, b);\n\t } else if (typeof a === 'object' && a !== null) {\n\t return !this.objectsDiffer(a, b);\n\t }\n\t\n\t return a === b;\n\t }\n\t};\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(1);\n\t\n\tvar convertValidationsToObject = function convertValidationsToObject(validations) {\n\t\n\t if (typeof validations === 'string') {\n\t\n\t return validations.split(/\\,(?![^{\\[]*[}\\]])/g).reduce(function (validations, validation) {\n\t var args = validation.split(':');\n\t var validateMethod = args.shift();\n\t\n\t args = args.map(function (arg) {\n\t try {\n\t return JSON.parse(arg);\n\t } catch (e) {\n\t return arg; // It is a string if it can not parse it\n\t }\n\t });\n\t\n\t if (args.length > 1) {\n\t throw new Error('Formsy does not support multiple args on string validations. Use object format of validations instead.');\n\t }\n\t\n\t validations[validateMethod] = args.length ? args[0] : true;\n\t return validations;\n\t }, {});\n\t }\n\t\n\t return validations || {};\n\t};\n\t\n\tmodule.exports = {\n\t getInitialState: function getInitialState() {\n\t return {\n\t _value: this.props.value,\n\t _isRequired: false,\n\t _isValid: true,\n\t _isPristine: true,\n\t _pristineValue: this.props.value,\n\t _validationError: '',\n\t _externalError: null,\n\t _formSubmitted: false\n\t };\n\t },\n\t getDefaultProps: function getDefaultProps() {\n\t return {\n\t validationError: '',\n\t validationErrors: {}\n\t };\n\t },\n\t\n\t componentWillMount: function componentWillMount() {\n\t var configure = (function () {\n\t this.setValidations(this.props.validations, this.props.required);\n\t this.props._attachToForm(this);\n\t }).bind(this);\n\t\n\t if (!this.props.name) {\n\t throw new Error('Form Input requires a name property when used');\n\t }\n\t\n\t if (!this.props._attachToForm) {\n\t return setTimeout((function () {\n\t if (!this.isMounted()) return;\n\t if (!this.props._attachToForm) {\n\t throw new Error('Form Mixin requires component to be nested in a Form');\n\t }\n\t configure();\n\t }).bind(this), 0);\n\t }\n\t configure();\n\t },\n\t\n\t // We have to make the validate method is kept when new props are added\n\t componentWillReceiveProps: function componentWillReceiveProps(nextProps) {\n\t this.setValidations(nextProps.validations, nextProps.required);\n\t },\n\t\n\t componentDidUpdate: function componentDidUpdate(prevProps) {\n\t\n\t // If the value passed has changed, set it. If value is not passed it will\n\t // internally update, and this will never run\n\t if (!utils.isSame(this.props.value, prevProps.value)) {\n\t this.setValue(this.props.value);\n\t }\n\t },\n\t\n\t // Detach it when component unmounts\n\t componentWillUnmount: function componentWillUnmount() {\n\t this.props._detachFromForm(this);\n\t },\n\t\n\t setValidations: function setValidations(validations, required) {\n\t\n\t // Add validations to the store itself as the props object can not be modified\n\t this._validations = convertValidationsToObject(validations) || {};\n\t this._requiredValidations = required === true ? { isDefaultRequiredValue: true } : convertValidationsToObject(required);\n\t },\n\t\n\t // We validate after the value has been set\n\t setValue: function setValue(value) {\n\t this.setState({\n\t _value: value,\n\t _isPristine: false\n\t }, (function () {\n\t this.props._validate(this);\n\t }).bind(this));\n\t },\n\t resetValue: function resetValue() {\n\t this.setState({\n\t _value: this.state._pristineValue,\n\t _isPristine: true\n\t }, function () {\n\t this.props._validate(this);\n\t });\n\t },\n\t getValue: function getValue() {\n\t return this.state._value;\n\t },\n\t hasValue: function hasValue() {\n\t return this.state._value !== '';\n\t },\n\t getErrorMessage: function getErrorMessage() {\n\t return !this.isValid() || this.showRequired() ? this.state._externalError || this.state._validationError : null;\n\t },\n\t isFormDisabled: function isFormDisabled() {\n\t return this.props._isFormDisabled();\n\t },\n\t isValid: function isValid() {\n\t return this.state._isValid;\n\t },\n\t isPristine: function isPristine() {\n\t return this.state._isPristine;\n\t },\n\t isFormSubmitted: function isFormSubmitted() {\n\t return this.state._formSubmitted;\n\t },\n\t isRequired: function isRequired() {\n\t return !!this.props.required;\n\t },\n\t showRequired: function showRequired() {\n\t return this.state._isRequired;\n\t },\n\t showError: function showError() {\n\t return !this.showRequired() && !this.isValid();\n\t },\n\t isValidValue: function isValidValue(value) {\n\t return this.props._isValidValue.call(null, this, value);\n\t }\n\t};\n\n/***/ },\n/* 3 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar isExisty = function isExisty(value) {\n\t return value !== null && value !== undefined;\n\t};\n\t\n\tvar validations = {\n\t isDefaultRequiredValue: function isDefaultRequiredValue(values, value) {\n\t return value === undefined || value === '';\n\t },\n\t hasValue: function hasValue(values, value) {\n\t return !!value;\n\t },\n\t matchRegexp: function matchRegexp(values, value, regexp) {\n\t return isExisty(value) && regexp.test(value);\n\t },\n\t isUndefined: function isUndefined(values, value) {\n\t return value === undefined;\n\t },\n\t isEmptyString: function isEmptyString(values, value) {\n\t return value === '';\n\t },\n\t isEmail: function isEmail(values, value) {\n\t return validations.matchRegexp(values, value, /^((([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);\n\t },\n\t isTrue: function isTrue(values, value) {\n\t return value === true;\n\t },\n\t isFalse: function isFalse(values, value) {\n\t return value === false;\n\t },\n\t isNumeric: function isNumeric(values, value) {\n\t if (!isExisty(value)) {\n\t return false;\n\t }\n\t if (typeof value === 'number') {\n\t return true;\n\t } else {\n\t var matchResults = value.match(/[-+]?(\\d*[.])?\\d+/);\n\t if (!!matchResults) {\n\t return matchResults[0] == value;\n\t } else {\n\t return false;\n\t }\n\t }\n\t },\n\t isAlpha: function isAlpha(values, value) {\n\t return value && /^[a-zA-Z]+$/.test(value);\n\t },\n\t isWords: function isWords(values, value) {\n\t return value && /^[a-zA-Z\\s]+$/.test(value);\n\t },\n\t isSpecialWords: function isSpecialWords(values, value) {\n\t return !value || /^[a-zA-Z\\s\\u00C0-\\u017F]+$/.test(value);\n\t },\n\t isLength: function isLength(values, value, length) {\n\t return isExisty(value) && value.length === length;\n\t },\n\t equals: function equals(values, value, eql) {\n\t return value == eql;\n\t },\n\t equalsField: function equalsField(values, value, field) {\n\t return value == values[field];\n\t },\n\t maxLength: function maxLength(values, value, length) {\n\t return isExisty(value) && value.length <= length;\n\t },\n\t minLength: function minLength(values, value, length) {\n\t return isExisty(value) && value.length >= length;\n\t }\n\t};\n\t\n\tmodule.exports = validations;\n\n/***/ },\n/* 4 */\n/***/ function(module, exports, __webpack_require__) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_4__;\n\n/***/ }\n/******/ ])\n});\n;\n\n\n/** WEBPACK FOOTER **\n ** formsy-react.js\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 70c91fb7cdf635a539c0\n **/","var React = global.React || require('react');\nvar Formsy = {};\nvar validationRules = require('./validationRules.js');\nvar utils = require('./utils.js');\nvar Mixin = require('./Mixin.js');\nvar options = {};\n\nFormsy.Mixin = Mixin;\n\nFormsy.defaults = function (passedOptions) {\n options = passedOptions;\n};\n\nFormsy.addValidationRule = function (name, func) {\n validationRules[name] = func;\n};\n\nFormsy.Form = React.createClass({\n getInitialState: function () {\n return {\n isValid: true,\n isSubmitting: false,\n canChange: false\n };\n },\n getDefaultProps: function () {\n return {\n onSuccess: function () {},\n onError: function () {},\n onSubmit: function () {},\n onValidSubmit: function () {},\n onInvalidSubmit: function () {},\n onSubmitted: function () {},\n onValid: function () {},\n onInvalid: function () {},\n onChange: function () {},\n validationErrors: null\n };\n },\n\n // Add a map to store the inputs of the form, a model to store\n // the values of the form and register child inputs\n componentWillMount: function () {\n this.inputs = {};\n this.model = {};\n },\n\n componentDidMount: function () {\n this.validateForm();\n },\n\n componentWillUpdate: function () {\n \n // Keep a reference to input keys before form updates,\n // to check if inputs has changed after render\n this.prevInputKeys = Object.keys(this.inputs);\n\n },\n\n componentDidUpdate: function () {\n \n if (this.props.validationErrors) {\n this.setInputValidationErrors(this.props.validationErrors);\n }\n\n var newInputKeys = Object.keys(this.inputs);\n if (utils.arraysDiffer(this.prevInputKeys, newInputKeys)) {\n this.validateForm();\n }\n\n },\n\n reset: function () {\n this.setFormPristine(true);\n this.resetModel();\n },\n\n // Update model, submit to url prop and send the model\n submit: function (event) {\n\n event && event.preventDefault();\n\n // Trigger form as not pristine.\n // If any inputs have not been touched yet this will make them dirty\n // so validation becomes visible (if based on isPristine)\n this.setFormPristine(false);\n this.updateModel();\n var model = this.mapModel();\n this.props.onSubmit(model, this.resetModel, this.updateInputsWithError);\n this.state.isValid ? this.props.onValidSubmit(model, this.resetModel, this.updateInputsWithError) : this.props.onInvalidSubmit(model, this.resetModel, this.updateInputsWithError);\n\n },\n\n mapModel: function () {\n return this.props.mapping ? this.props.mapping(this.model) : this.model;\n },\n\n // Goes through all registered components and\n // updates the model values\n updateModel: function () {\n Object.keys(this.inputs).forEach(function (name) {\n var component = this.inputs[name];\n this.model[name] = component.state._value;\n }.bind(this));\n },\n\n // Reset each key in the model to the original / initial value\n resetModel: function () {\n Object.keys(this.inputs).forEach(function (name) {\n this.inputs[name].resetValue();\n }.bind(this));\n this.validateForm();\n },\n\n setInputValidationErrors: function (errors) {\n Object.keys(this.inputs).forEach(function (name, index) {\n var component = this.inputs[name];\n var args = [{\n _isValid: !(name in errors),\n _validationError: errors[name]\n }];\n component.setState.apply(component, args);\n }.bind(this));\n },\n\n // Go through errors from server and grab the components\n // stored in the inputs map. Change their state to invalid\n // and set the serverError message\n updateInputsWithError: function (errors) {\n Object.keys(errors).forEach(function (name, index) {\n var component = this.inputs[name];\n\n if (!component) {\n throw new Error('You are trying to update an input that does not exists. Verify errors object with input names. ' + JSON.stringify(errors));\n }\n\n var args = [{\n _isValid: false,\n _externalError: errors[name]\n }];\n component.setState.apply(component, args);\n }.bind(this));\n },\n\n // Traverse the children and children of children to find\n // all inputs by checking the name prop. Maybe do a better\n // check here\n traverseChildrenAndRegisterInputs: function (children) {\n\n if (typeof children !== 'object' || children === null) {\n return children;\n }\n return React.Children.map(children, function (child) {\n\n if (typeof child !== 'object' || child === null) {\n return child;\n }\n\n if (child.props && child.props.name) {\n\n return React.cloneElement(child, {\n _attachToForm: this.attachToForm,\n _detachFromForm: this.detachFromForm,\n _validate: this.validate,\n _isFormDisabled: this.isFormDisabled,\n _isValidValue: function (component, value) {\n return this.runValidation(component, value).isValid;\n }.bind(this)\n }, child.props && child.props.children);\n } else {\n return React.cloneElement(child, {}, this.traverseChildrenAndRegisterInputs(child.props && child.props.children));\n }\n\n }, this);\n\n },\n\n isFormDisabled: function () {\n return this.props.disabled;\n },\n\n getCurrentValues: function () {\n return Object.keys(this.inputs).reduce(function (data, name) {\n var component = this.inputs[name];\n data[name] = component.state._value;\n return data;\n }.bind(this), {});\n },\n\n setFormPristine: function (isPristine) {\n var inputs = this.inputs;\n var inputKeys = Object.keys(inputs);\n\n this.setState({\n _formSubmitted: !isPristine\n })\n\n // Iterate through each component and set it as pristine\n // or \"dirty\".\n inputKeys.forEach(function (name, index) {\n var component = inputs[name];\n component.setState({\n _formSubmitted: !isPristine,\n _isPristine: isPristine\n });\n }.bind(this));\n },\n\n // Use the binded values and the actual input value to\n // validate the input and set its state. Then check the\n // state of the form itself\n validate: function (component) {\n\n // Trigger onChange\n if (this.state.canChange) {\n this.props.onChange(this.getCurrentValues());\n }\n\n var validation = this.runValidation(component);\n // Run through the validations, split them up and call\n // the validator IF there is a value or it is required\n component.setState({\n _isValid: validation.isValid,\n _isRequired: validation.isRequired,\n _validationError: validation.error,\n _externalError: null\n }, this.validateForm);\n\n },\n\n // Checks validation on current value or a passed value\n runValidation: function (component, value) {\n\n var currentValues = this.getCurrentValues();\n var validationErrors = component.props.validationErrors;\n var validationError = component.props.validationError;\n value = arguments.length === 2 ? value : component.state._value;\n\n var validationResults = this.runRules(value, currentValues, component._validations);\n var requiredResults = this.runRules(value, currentValues, component._requiredValidations);\n\n // the component defines an explicit validate function\n if (typeof component.validate === \"function\") {\n validationResults.failed = component.validate() ? [] : ['failed'];\n }\n\n var isRequired = Object.keys(component._requiredValidations).length ? !!requiredResults.success.length : false;\n var isValid = !validationResults.failed.length && !(this.props.validationErrors && this.props.validationErrors[component.props.name]);\n\n return {\n isRequired: isRequired,\n isValid: isRequired ? false : isValid,\n error: (function () {\n\n if (isValid && !isRequired) {\n return '';\n }\n\n if (validationResults.errors.length) {\n return validationResults.errors[0];\n }\n\n if (this.props.validationErrors && this.props.validationErrors[component.props.name]) {\n return this.props.validationErrors[component.props.name];\n }\n\n if (isRequired) {\n return validationErrors[requiredResults.success[0]] || null;\n }\n\n if (!isValid) {\n return validationErrors[validationResults.failed[0]] || validationError;\n }\n\n }.call(this))\n };\n\n },\n\n runRules: function (value, currentValues, validations) {\n\n var results = {\n errors: [],\n failed: [],\n success: []\n };\n if (Object.keys(validations).length) {\n Object.keys(validations).forEach(function (validationMethod) {\n\n if (validationRules[validationMethod] && typeof validations[validationMethod] === 'function') {\n throw new Error('Formsy does not allow you to override default validations: ' + validationMethod);\n }\n\n if (!validationRules[validationMethod] && typeof validations[validationMethod] !== 'function') {\n throw new Error('Formsy does not have the validation rule: ' + validationMethod);\n }\n\n if (typeof validations[validationMethod] === 'function') {\n var validation = validations[validationMethod](currentValues, value);\n if (typeof validation === 'string') {\n results.errors.push(validation);\n results.failed.push(validationMethod);\n } else if (!validation) {\n results.failed.push(validationMethod);\n }\n return;\n\n } else if (typeof validations[validationMethod] !== 'function') {\n var validation = validationRules[validationMethod](currentValues, value, validations[validationMethod]);\n if (typeof validation === 'string') {\n results.errors.push(validation);\n results.failed.push(validationMethod);\n } else if (!validation) {\n results.failed.push(validationMethod);\n } else {\n results.success.push(validationMethod);\n }\n return;\n\n }\n\n return results.success.push(validationMethod);\n\n });\n }\n\n return results;\n\n },\n\n // Validate the form by going through all child input components\n // and check their state\n validateForm: function () {\n var allIsValid = true;\n var inputs = this.inputs;\n var inputKeys = Object.keys(inputs);\n\n // We need a callback as we are validating all inputs again. This will\n // run when the last component has set its state\n var onValidationComplete = function () {\n inputKeys.forEach(function (name) {\n if (!inputs[name].state._isValid) {\n allIsValid = false;\n }\n }.bind(this));\n\n this.setState({\n isValid: allIsValid\n });\n\n if (allIsValid) {\n this.props.onValid();\n } else {\n this.props.onInvalid();\n }\n\n // Tell the form that it can start to trigger change events\n this.setState({\n canChange: true\n });\n\n }.bind(this);\n\n // Run validation again in case affected by other inputs. The\n // last component validated will run the onValidationComplete callback\n inputKeys.forEach(function (name, index) {\n var component = inputs[name];\n var validation = this.runValidation(component);\n if (validation.isValid && component.state._externalError) {\n validation.isValid = false;\n }\n component.setState({\n _isValid: validation.isValid,\n _isRequired: validation.isRequired,\n _validationError: validation.error,\n _externalError: !validation.isValid && component.state._externalError ? component.state._externalError : null\n }, index === inputKeys.length - 1 ? onValidationComplete : null);\n }.bind(this));\n\n // If there are no inputs, set state where form is ready to trigger\n // change event. New inputs might be added later\n if (!inputKeys.length && this.isMounted()) {\n this.setState({\n canChange: true\n });\n }\n },\n\n // Method put on each input component to register\n // itself to the form\n attachToForm: function (component) {\n this.inputs[component.props.name] = component;\n this.model[component.props.name] = component.state._value;\n this.validate(component);\n },\n\n // Method put on each input component to unregister\n // itself from the form\n detachFromForm: function (component) {\n delete this.inputs[component.props.name];\n delete this.model[component.props.name];\n },\n render: function () {\n\n return React.DOM.form({\n onSubmit: this.submit,\n className: this.props.className\n },\n this.traverseChildrenAndRegisterInputs(this.props.children)\n );\n\n }\n});\n\nif (!global.exports && !global.module && (!global.define || !global.define.amd)) {\n global.Formsy = Formsy;\n}\n\nmodule.exports = Formsy;\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/main.js\n **/","module.exports = {\n arraysDiffer: function (a, b) {\n var isDifferent = false;\n if (a.length !== b.length) {\n isDifferent = true;\n } else {\n a.forEach(function (item, index) {\n if (!this.isSame(item, b[index])) {\n isDifferent = true;\n }\n }, this);\n }\n return isDifferent;\n },\n objectsDiffer: function (a, b) {\n var isDifferent = false;\n if (Object.keys(a).length !== Object.keys(b).length) {\n isDifferent = true;\n } else {\n Object.keys(a).forEach(function (key) {\n if (!this.isSame(a[key], b[key])) {\n isDifferent = true;\n }\n }, this);\n }\n return isDifferent; \n },\n isSame: function (a, b) {\n\n if (Array.isArray(a)) {\n return !this.arraysDiffer(a, b);\n } else if (typeof a === 'object' && a !== null) {\n return !this.objectsDiffer(a, b);\n }\n\n return a === b;\n }\n};\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/utils.js\n **/","var utils = require('./utils.js');\n\nvar convertValidationsToObject = function (validations) {\n\n if (typeof validations === 'string') {\n\n return validations.split(/\\,(?![^{\\[]*[}\\]])/g).reduce(function (validations, validation) {\n var args = validation.split(':');\n var validateMethod = args.shift();\n\n args = args.map(function (arg) {\n try {\n return JSON.parse(arg);\n } catch (e) {\n return arg; // It is a string if it can not parse it\n }\n });\n\n if (args.length > 1) {\n throw new Error('Formsy does not support multiple args on string validations. Use object format of validations instead.');\n }\n\n validations[validateMethod] = args.length ? args[0] : true;\n return validations;\n }, {});\n\n }\n\n return validations || {};\n};\n\nmodule.exports = {\n getInitialState: function () {\n return {\n _value: this.props.value,\n _isRequired: false,\n _isValid: true,\n _isPristine: true,\n _pristineValue: this.props.value,\n _validationError: '',\n _externalError: null,\n _formSubmitted: false\n };\n },\n getDefaultProps: function () {\n return {\n validationError: '',\n validationErrors: {}\n };\n },\n\n componentWillMount: function () {\n var configure = function () {\n this.setValidations(this.props.validations, this.props.required);\n this.props._attachToForm(this);\n }.bind(this);\n\n if (!this.props.name) {\n throw new Error('Form Input requires a name property when used');\n }\n\n if (!this.props._attachToForm) {\n return setTimeout(function () {\n if (!this.isMounted()) return;\n if (!this.props._attachToForm) {\n throw new Error('Form Mixin requires component to be nested in a Form');\n }\n configure();\n }.bind(this), 0);\n }\n configure();\n },\n\n // We have to make the validate method is kept when new props are added\n componentWillReceiveProps: function (nextProps) {\n this.setValidations(nextProps.validations, nextProps.required);\n },\n\n componentDidUpdate: function (prevProps) {\n\n // If the value passed has changed, set it. If value is not passed it will\n // internally update, and this will never run\n if (!utils.isSame(this.props.value, prevProps.value)) {\n this.setValue(this.props.value);\n }\n },\n\n // Detach it when component unmounts\n componentWillUnmount: function () {\n this.props._detachFromForm(this);\n },\n\n setValidations: function (validations, required) {\n\n // Add validations to the store itself as the props object can not be modified\n this._validations = convertValidationsToObject(validations) || {};\n this._requiredValidations = required === true ? {isDefaultRequiredValue: true} : convertValidationsToObject(required);\n\n },\n\n // We validate after the value has been set\n setValue: function (value) {\n this.setState({\n _value: value,\n _isPristine: false\n }, function () {\n this.props._validate(this);\n }.bind(this));\n },\n resetValue: function () {\n this.setState({\n _value: this.state._pristineValue,\n _isPristine: true\n }, function () {\n this.props._validate(this);\n });\n },\n getValue: function () {\n return this.state._value;\n },\n hasValue: function () {\n return this.state._value !== '';\n },\n getErrorMessage: function () {\n return !this.isValid() || this.showRequired() ? (this.state._externalError || this.state._validationError) : null;\n },\n isFormDisabled: function () {\n return this.props._isFormDisabled();\n },\n isValid: function () {\n return this.state._isValid;\n },\n isPristine: function () {\n return this.state._isPristine;\n },\n isFormSubmitted: function () {\n return this.state._formSubmitted;\n },\n isRequired: function () {\n return !!this.props.required;\n },\n showRequired: function () {\n return this.state._isRequired;\n },\n showError: function () {\n return !this.showRequired() && !this.isValid();\n },\n isValidValue: function (value) {\n return this.props._isValidValue.call(null, this, value);\n }\n};\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/Mixin.js\n **/","var isExisty = function (value) {\n return value !== null && value !== undefined;\n};\n\nvar validations = {\n isDefaultRequiredValue: function (values, value) {\n return value === undefined || value === '';\n },\n hasValue: function (values, value) {\n return !!value;\n },\n matchRegexp: function (values, value, regexp) {\n return isExisty(value) && regexp.test(value);\n },\n isUndefined: function (values, value) {\n return value === undefined;\n },\n isEmptyString: function (values, value) {\n return value === '';\n },\n isEmail: function (values, value) {\n return validations.matchRegexp(values, value, /^((([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);\n },\n isTrue: function (values, value) {\n return value === true;\n },\n isFalse: function (values, value) {\n return value === false;\n },\n isNumeric: function (values, value) {\n if (!isExisty(value)) {\n return false;\n }\n if (typeof value === 'number') {\n return true;\n } else {\n var matchResults = value.match(/[-+]?(\\d*[.])?\\d+/);\n if (!!matchResults) {\n return matchResults[0] == value;\n } else {\n return false;\n }\n }\n },\n isAlpha: function (values, value) {\n return value && /^[a-zA-Z]+$/.test(value);\n },\n isWords: function (values, value) {\n return value && /^[a-zA-Z\\s]+$/.test(value);\n },\n isSpecialWords: function (values, value) {\n return !value || /^[a-zA-Z\\s\\u00C0-\\u017F]+$/.test(value);\n },\n isLength: function (values, value, length) {\n return isExisty(value) && value.length === length;\n },\n equals: function (values, value, eql) {\n return value == eql;\n },\n equalsField: function (values, value, field) {\n return value == values[field];\n },\n maxLength: function (values, value, length) {\n return isExisty(value) && value.length <= length;\n },\n minLength: function (values, value, length) {\n return isExisty(value) && value.length >= length;\n }\n};\n\nmodule.exports = validations;\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/validationRules.js\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_4__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"react\"\n ** module id = 4\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///formsy-react.js","webpack:///webpack/bootstrap 646d477f5240abe57846","webpack:///./src/main.js","webpack:///./src/utils.js","webpack:///./src/Mixin.js","webpack:///./src/validationRules.js","webpack:///external \"react\""],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_4__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","global","React","Formsy","validationRules","utils","Mixin","options","defaults","passedOptions","addValidationRule","name","func","Form","createClass","displayName","getInitialState","isValid","isSubmitting","canChange","getDefaultProps","onSuccess","onError","onSubmit","onValidSubmit","onInvalidSubmit","onSubmitted","onValid","onInvalid","onChange","validationErrors","preventExternalInvalidation","componentWillMount","inputs","model","componentDidMount","validateForm","componentWillUpdate","prevInputKeys","Object","keys","componentDidUpdate","props","setInputValidationErrors","newInputKeys","arraysDiffer","reset","data","setFormPristine","resetModel","submit","event","preventDefault","updateModel","mapModel","updateInputsWithError","state","mapping","reduce","mappedModel","key","keyArray","split","length","currentKey","shift","bind","forEach","component","_value","setValue","resetValue","errors","index","args","_isValid","_validationError","setState","apply","isChanged","isSame","getPristineValues","getCurrentValues","value","Error","JSON","stringify","_externalError","traverseChildrenAndRegisterInputs","children","Children","map","child","cloneElement","_attachToForm","attachToForm","_detachFromForm","detachFromForm","_validate","validate","_isFormDisabled","isFormDisabled","_isValidValue","runValidation","disabled","isPristine","inputKeys","_formSubmitted","_isPristine","validation","_isRequired","isRequired","error","currentValues","validationError","arguments","validationResults","runRules","_validations","requiredResults","_requiredValidations","failed","success","validations","results","validationMethod","push","allIsValid","onValidationComplete","isMounted","render","DOM","form","extend","className","a","b","isDifferent","item","objectsDiffer","Array","isArray","objects","slice","initialObject","returnedObject","object","convertValidationsToObject","validateMethod","arg","parse","e","_pristineValue","configure","setValidations","required","setTimeout","componentWillReceiveProps","nextProps","prevProps","componentWillUnmount","isDefaultRequiredValue","getValue","hasValue","getErrorMessage","showRequired","isFormSubmitted","showError","isValidValue","isExisty","undefined","values","_isExisty","_x","_x2","toString","matchRegexp","regexp","test","isUndefined","isEmptyString","isEmail","isUrl","isTrue","isFalse","isNumeric","matchResults","match","isAlpha","isWords","isSpecialWords","isLength","equals","eql","equalsField","field","maxLength","minLength"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,EAAAG,QAAA,UACA,kBAAAC,gBAAAC,IACAD,QAAA,SAAAJ,GACA,gBAAAC,SACAA,QAAA,OAAAD,EAAAG,QAAA,UAEAJ,EAAA,OAAAC,EAAAD,EAAA,QACCO,KAAA,SAAAC,GACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAT,OAGA,IAAAC,GAAAS,EAAAD,IACAT,WACAW,GAAAF,EACAG,QAAA,EAUA,OANAL,GAAAE,GAAAI,KAAAZ,EAAAD,QAAAC,IAAAD,QAAAQ,GAGAP,EAAAW,QAAA,EAGAX,EAAAD,QAvBA,GAAAU,KAqCA,OATAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,GAGAR,EAAA,KDgBM,SAASP,EAAQD,EAASQ,IAEH,SAASS,GAAS,YExD/C,IAAIC,GAAQD,EAAOC,OAASV,EAAQ,GAChCW,KACAC,EAAkBZ,EAAQ,GAC1Ba,EAAQb,EAAQ,GAChBc,EAAQd,EAAQ,GAChBe,IAEJJ,GAAOG,MAAQA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AUT,EAAQxF,GAC/B,MAAiB,KAAVA,GAETkG,QAAS,SAAUV,EAAQxF,GACzB,MAAOwC,GAAYqD,YAAYL,EAAQxF,EAAO,44BAEhDmG,MAAO,SAAUX,EAAQxF,GACvB,MAAOwC,GAAYqD,YAAYL,EAAQxF,EAAO,yqCAEhDoG,OAAQ,SAAUZ,EAAQxF,GACxB,MAAOA,MAAU,GAEnBqG,QAAS,SAAUb,EAAQxF,GACzB,MAAOA,MAAU,GAEnBsG,UAAW,SAAUd,EAAQxF,GAC3B,IAAKsF,EAAStF,GACV,OAAO,CAEX,IAAqB,gBAAVA,GACT,OAAO,CAEP,IAAIuG,GAAevG,EAAMwG,MAAM,oBAC/B,OAAMD,GACGA,EAAa,IAAMvG,GAEnB,GAIbyG,QAAS,SAAUjB,EAAQxF,GACzB,MAAOA,IAAS,cAAc+F,KAAK/F,IAErC0G,QAAS,SAAUlB,EAAQxF,GACzB,MAAOA,IAAS,gBAAgB+F,KAAK/F,IAEvC2G,eAAgB,SAAUnB,EAAQxF,GAChC,OAAQA,GAAS,6BAA6B+F,KAAK/F,IAErD4G,SAAU,SAAUpB,EAAQxF,EAAOpB,GACjC,MAAO0G,GAAStF,IAAUA,EAAMpB,SAAWA,GAE7CiI,OAAQ,SAAUrB,EAAQxF,EAAO8G,GAC/B,MAAO9G,IAAS8G,GAElBC,YAAa,SAAUvB,EAAQxF,EAAOgH,GACpC,MAAOhH,IAASwF,EAAOwB,IAEzBC,UAAW,SAAUzB,EAAQxF,EAAOpB,GAClC,MAAO0G,GAAStF,IAAUA,EAAMpB,QAAUA,GAE5CsI,UAAW,SAAU1B,EAAQxF,EAAOpB,GAClC,MAAO0G,GAAStF,IAAUA,EAAMpB,QAAUA,GAI9C9E,GAAOD,QAAU2I,GL2tBX,SAAS1I,EAAQD,EAASQ,GMpyBhCP,EAAAD,QAAAM","file":"formsy-react.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"react\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Formsy\"] = factory(require(\"react\"));\n\telse\n\t\troot[\"Formsy\"] = factory(root[\"react\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_4__) {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\n **/","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"react\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Formsy\"] = factory(require(\"react\"));\n\telse\n\t\troot[\"Formsy\"] = factory(root[\"react\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_4__) {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t/* WEBPACK VAR INJECTION */(function(global) {'use strict';\n\t\n\tvar React = global.React || __webpack_require__(4);\n\tvar Formsy = {};\n\tvar validationRules = __webpack_require__(3);\n\tvar utils = __webpack_require__(1);\n\tvar Mixin = __webpack_require__(2);\n\tvar options = {};\n\t\n\tFormsy.Mixin = Mixin;\n\t\n\tFormsy.defaults = function (passedOptions) {\n\t options = passedOptions;\n\t};\n\t\n\tFormsy.addValidationRule = function (name, func) {\n\t validationRules[name] = func;\n\t};\n\t\n\tFormsy.Form = React.createClass({\n\t displayName: 'Form',\n\t\n\t getInitialState: function getInitialState() {\n\t return {\n\t isValid: true,\n\t isSubmitting: false,\n\t canChange: false\n\t };\n\t },\n\t getDefaultProps: function getDefaultProps() {\n\t return {\n\t onSuccess: function onSuccess() {},\n\t onError: function onError() {},\n\t onSubmit: function onSubmit() {},\n\t onValidSubmit: function onValidSubmit() {},\n\t onInvalidSubmit: function onInvalidSubmit() {},\n\t onSubmitted: function onSubmitted() {},\n\t onValid: function onValid() {},\n\t onInvalid: function onInvalid() {},\n\t onChange: function onChange() {},\n\t validationErrors: null,\n\t preventExternalInvalidation: false\n\t };\n\t },\n\t\n\t // Add a map to store the inputs of the form, a model to store\n\t // the values of the form and register child inputs\n\t componentWillMount: function componentWillMount() {\n\t this.inputs = {};\n\t this.model = {};\n\t },\n\t\n\t componentDidMount: function componentDidMount() {\n\t this.validateForm();\n\t },\n\t\n\t componentWillUpdate: function componentWillUpdate() {\n\t\n\t // Keep a reference to input keys before form updates,\n\t // to check if inputs has changed after render\n\t this.prevInputKeys = Object.keys(this.inputs);\n\t },\n\t\n\t componentDidUpdate: function componentDidUpdate() {\n\t\n\t if (this.props.validationErrors) {\n\t this.setInputValidationErrors(this.props.validationErrors);\n\t }\n\t\n\t var newInputKeys = Object.keys(this.inputs);\n\t if (utils.arraysDiffer(this.prevInputKeys, newInputKeys)) {\n\t this.validateForm();\n\t }\n\t },\n\t\n\t // Allow resetting to specified data\n\t reset: function reset(data) {\n\t this.setFormPristine(true);\n\t this.resetModel(data);\n\t },\n\t\n\t // Update model, submit to url prop and send the model\n\t submit: function submit(event) {\n\t\n\t event && event.preventDefault();\n\t\n\t // Trigger form as not pristine.\n\t // If any inputs have not been touched yet this will make them dirty\n\t // so validation becomes visible (if based on isPristine)\n\t this.setFormPristine(false);\n\t this.updateModel();\n\t var model = this.mapModel();\n\t this.props.onSubmit(model, this.resetModel, this.updateInputsWithError);\n\t this.state.isValid ? this.props.onValidSubmit(model, this.resetModel, this.updateInputsWithError) : this.props.onInvalidSubmit(model, this.resetModel, this.updateInputsWithError);\n\t },\n\t\n\t mapModel: function mapModel() {\n\t if (this.props.mapping) {\n\t return this.props.mapping(this.model);\n\t } else {\n\t return Object.keys(this.model).reduce((function (mappedModel, key) {\n\t\n\t var keyArray = key.split('.');\n\t while (keyArray.length) {\n\t var currentKey = keyArray.shift();\n\t mappedModel[currentKey] = keyArray.length ? mappedModel[currentKey] || {} : this.model[key];\n\t }\n\t\n\t return mappedModel;\n\t }).bind(this), {});\n\t }\n\t },\n\t\n\t // Goes through all registered components and\n\t // updates the model values\n\t updateModel: function updateModel() {\n\t Object.keys(this.inputs).forEach((function (name) {\n\t var component = this.inputs[name];\n\t this.model[name] = component.state._value;\n\t }).bind(this));\n\t },\n\t\n\t // Reset each key in the model to the original / initial / specified value\n\t resetModel: function resetModel(data) {\n\t Object.keys(this.inputs).forEach((function (name) {\n\t if (data && data[name]) {\n\t this.inputs[name].setValue(data[name]);\n\t } else {\n\t this.inputs[name].resetValue();\n\t }\n\t }).bind(this));\n\t this.validateForm();\n\t },\n\t\n\t setInputValidationErrors: function setInputValidationErrors(errors) {\n\t Object.keys(this.inputs).forEach((function (name, index) {\n\t var component = this.inputs[name];\n\t var args = [{\n\t _isValid: !(name in errors),\n\t _validationError: errors[name]\n\t }];\n\t component.setState.apply(component, args);\n\t }).bind(this));\n\t },\n\t\n\t // Checks if the values have changed from their initial value\n\t isChanged: function isChanged() {\n\t return !utils.isSame(this.getPristineValues(), this.getCurrentValues());\n\t },\n\t\n\t getPristineValues: function getPristineValues() {\n\t var inputs = this.inputs;\n\t return Object.keys(inputs).reduce(function (data, name) {\n\t var component = inputs[name];\n\t data[name] = component.props.value;\n\t return data;\n\t }, {});\n\t },\n\t\n\t // Go through errors from server and grab the components\n\t // stored in the inputs map. Change their state to invalid\n\t // and set the serverError message\n\t updateInputsWithError: function updateInputsWithError(errors) {\n\t Object.keys(errors).forEach((function (name, index) {\n\t var component = this.inputs[name];\n\t\n\t if (!component) {\n\t throw new Error('You are trying to update an input that does not exist. Verify errors object with input names. ' + JSON.stringify(errors));\n\t }\n\t var args = [{\n\t _isValid: this.props.preventExternalInvalidation || false,\n\t _externalError: errors[name]\n\t }];\n\t component.setState.apply(component, args);\n\t }).bind(this));\n\t },\n\t\n\t // Traverse the children and children of children to find\n\t // all inputs by checking the name prop. Maybe do a better\n\t // check here\n\t traverseChildrenAndRegisterInputs: function traverseChildrenAndRegisterInputs(children) {\n\t\n\t if (typeof children !== 'object' || children === null) {\n\t return children;\n\t }\n\t return React.Children.map(children, function (child) {\n\t\n\t if (typeof child !== 'object' || child === null) {\n\t return child;\n\t }\n\t\n\t if (child.props && child.props.name) {\n\t\n\t return React.cloneElement(child, {\n\t _attachToForm: this.attachToForm,\n\t _detachFromForm: this.detachFromForm,\n\t _validate: this.validate,\n\t _isFormDisabled: this.isFormDisabled,\n\t _isValidValue: (function (component, value) {\n\t return this.runValidation(component, value).isValid;\n\t }).bind(this)\n\t }, child.props && child.props.children);\n\t } else {\n\t return React.cloneElement(child, {}, this.traverseChildrenAndRegisterInputs(child.props && child.props.children));\n\t }\n\t }, this);\n\t },\n\t\n\t isFormDisabled: function isFormDisabled() {\n\t return this.props.disabled;\n\t },\n\t\n\t getCurrentValues: function getCurrentValues() {\n\t return Object.keys(this.inputs).reduce((function (data, name) {\n\t var component = this.inputs[name];\n\t data[name] = component.state._value;\n\t return data;\n\t }).bind(this), {});\n\t },\n\t\n\t setFormPristine: function setFormPristine(isPristine) {\n\t var inputs = this.inputs;\n\t var inputKeys = Object.keys(inputs);\n\t\n\t this.setState({\n\t _formSubmitted: !isPristine\n\t });\n\t\n\t // Iterate through each component and set it as pristine\n\t // or \"dirty\".\n\t inputKeys.forEach((function (name, index) {\n\t var component = inputs[name];\n\t component.setState({\n\t _formSubmitted: !isPristine,\n\t _isPristine: isPristine\n\t });\n\t }).bind(this));\n\t },\n\t\n\t // Use the binded values and the actual input value to\n\t // validate the input and set its state. Then check the\n\t // state of the form itself\n\t validate: function validate(component) {\n\t\n\t // Trigger onChange\n\t if (this.state.canChange) {\n\t this.props.onChange(this.getCurrentValues(), this.isChanged());\n\t }\n\t\n\t var validation = this.runValidation(component);\n\t // Run through the validations, split them up and call\n\t // the validator IF there is a value or it is required\n\t component.setState({\n\t _isValid: validation.isValid,\n\t _isRequired: validation.isRequired,\n\t _validationError: validation.error,\n\t _externalError: null\n\t }, this.validateForm);\n\t },\n\t\n\t // Checks validation on current value or a passed value\n\t runValidation: function runValidation(component, value) {\n\t\n\t var currentValues = this.getCurrentValues();\n\t var validationErrors = component.props.validationErrors;\n\t var validationError = component.props.validationError;\n\t value = arguments.length === 2 ? value : component.state._value;\n\t\n\t var validationResults = this.runRules(value, currentValues, component._validations);\n\t var requiredResults = this.runRules(value, currentValues, component._requiredValidations);\n\t\n\t // the component defines an explicit validate function\n\t if (typeof component.validate === 'function') {\n\t validationResults.failed = component.validate() ? [] : ['failed'];\n\t }\n\t\n\t var isRequired = Object.keys(component._requiredValidations).length ? !!requiredResults.success.length : false;\n\t var isValid = !validationResults.failed.length && !(this.props.validationErrors && this.props.validationErrors[component.props.name]);\n\t\n\t return {\n\t isRequired: isRequired,\n\t isValid: isRequired ? false : isValid,\n\t error: (function () {\n\t\n\t if (isValid && !isRequired) {\n\t return '';\n\t }\n\t\n\t if (validationResults.errors.length) {\n\t return validationResults.errors[0];\n\t }\n\t\n\t if (this.props.validationErrors && this.props.validationErrors[component.props.name]) {\n\t return this.props.validationErrors[component.props.name];\n\t }\n\t\n\t if (isRequired) {\n\t return validationErrors[requiredResults.success[0]] || null;\n\t }\n\t\n\t if (!isValid) {\n\t return validationErrors[validationResults.failed[0]] || validationError;\n\t }\n\t }).call(this)\n\t };\n\t },\n\t\n\t runRules: function runRules(value, currentValues, validations) {\n\t\n\t var results = {\n\t errors: [],\n\t failed: [],\n\t success: []\n\t };\n\t if (Object.keys(validations).length) {\n\t Object.keys(validations).forEach(function (validationMethod) {\n\t\n\t if (validationRules[validationMethod] && typeof validations[validationMethod] === 'function') {\n\t throw new Error('Formsy does not allow you to override default validations: ' + validationMethod);\n\t }\n\t\n\t if (!validationRules[validationMethod] && typeof validations[validationMethod] !== 'function') {\n\t throw new Error('Formsy does not have the validation rule: ' + validationMethod);\n\t }\n\t\n\t if (typeof validations[validationMethod] === 'function') {\n\t var validation = validations[validationMethod](currentValues, value);\n\t if (typeof validation === 'string') {\n\t results.errors.push(validation);\n\t results.failed.push(validationMethod);\n\t } else if (!validation) {\n\t results.failed.push(validationMethod);\n\t }\n\t return;\n\t } else if (typeof validations[validationMethod] !== 'function') {\n\t var validation = validationRules[validationMethod](currentValues, value, validations[validationMethod]);\n\t if (typeof validation === 'string') {\n\t results.errors.push(validation);\n\t results.failed.push(validationMethod);\n\t } else if (!validation) {\n\t results.failed.push(validationMethod);\n\t } else {\n\t results.success.push(validationMethod);\n\t }\n\t return;\n\t }\n\t\n\t return results.success.push(validationMethod);\n\t });\n\t }\n\t\n\t return results;\n\t },\n\t\n\t // Validate the form by going through all child input components\n\t // and check their state\n\t validateForm: function validateForm() {\n\t var allIsValid = true;\n\t var inputs = this.inputs;\n\t var inputKeys = Object.keys(inputs);\n\t\n\t // We need a callback as we are validating all inputs again. This will\n\t // run when the last component has set its state\n\t var onValidationComplete = (function () {\n\t inputKeys.forEach((function (name) {\n\t if (!inputs[name].state._isValid) {\n\t allIsValid = false;\n\t }\n\t }).bind(this));\n\t\n\t this.setState({\n\t isValid: allIsValid\n\t });\n\t\n\t if (allIsValid) {\n\t this.props.onValid();\n\t } else {\n\t this.props.onInvalid();\n\t }\n\t\n\t // Tell the form that it can start to trigger change events\n\t this.setState({\n\t canChange: true\n\t });\n\t }).bind(this);\n\t\n\t // Run validation again in case affected by other inputs. The\n\t // last component validated will run the onValidationComplete callback\n\t inputKeys.forEach((function (name, index) {\n\t var component = inputs[name];\n\t var validation = this.runValidation(component);\n\t if (validation.isValid && component.state._externalError) {\n\t validation.isValid = false;\n\t }\n\t component.setState({\n\t _isValid: validation.isValid,\n\t _isRequired: validation.isRequired,\n\t _validationError: validation.error,\n\t _externalError: !validation.isValid && component.state._externalError ? component.state._externalError : null\n\t }, index === inputKeys.length - 1 ? onValidationComplete : null);\n\t }).bind(this));\n\t\n\t // If there are no inputs, set state where form is ready to trigger\n\t // change event. New inputs might be added later\n\t if (!inputKeys.length && this.isMounted()) {\n\t this.setState({\n\t canChange: true\n\t });\n\t }\n\t },\n\t\n\t // Method put on each input component to register\n\t // itself to the form\n\t attachToForm: function attachToForm(component) {\n\t this.inputs[component.props.name] = component;\n\t this.model[component.props.name] = component.state._value;\n\t this.validate(component);\n\t },\n\t\n\t // Method put on each input component to unregister\n\t // itself from the form\n\t detachFromForm: function detachFromForm(component) {\n\t delete this.inputs[component.props.name];\n\t delete this.model[component.props.name];\n\t },\n\t render: function render() {\n\t\n\t return React.DOM.form(utils.extend({}, this.props, {\n\t onSubmit: this.submit,\n\t className: this.props.className\n\t }), this.traverseChildrenAndRegisterInputs(this.props.children));\n\t }\n\t});\n\t\n\tif (!global.exports && !global.module && (!global.define || !global.define.amd)) {\n\t global.Formsy = Formsy;\n\t}\n\t\n\tmodule.exports = Formsy;\n\t/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))\n\n/***/ },\n/* 1 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tmodule.exports = {\n\t arraysDiffer: function arraysDiffer(a, b) {\n\t var isDifferent = false;\n\t if (a.length !== b.length) {\n\t isDifferent = true;\n\t } else {\n\t a.forEach(function (item, index) {\n\t if (!this.isSame(item, b[index])) {\n\t isDifferent = true;\n\t }\n\t }, this);\n\t }\n\t return isDifferent;\n\t },\n\t\n\t objectsDiffer: function objectsDiffer(a, b) {\n\t var isDifferent = false;\n\t if (Object.keys(a).length !== Object.keys(b).length) {\n\t isDifferent = true;\n\t } else {\n\t Object.keys(a).forEach(function (key) {\n\t if (!this.isSame(a[key], b[key])) {\n\t isDifferent = true;\n\t }\n\t }, this);\n\t }\n\t return isDifferent;\n\t },\n\t\n\t isSame: function isSame(a, b) {\n\t if (typeof a !== typeof b) {\n\t return false;\n\t } else if (Array.isArray(a)) {\n\t return !this.arraysDiffer(a, b);\n\t } else if (typeof a === 'object' && a !== null && b !== null) {\n\t return !this.objectsDiffer(a, b);\n\t }\n\t\n\t return a === b;\n\t },\n\t extend: function extend() {\n\t var objects = [].slice.call(arguments);\n\t var initialObject = objects.shift();\n\t return objects.reduce(function (returnedObject, object) {\n\t return Object.keys(object).reduce(function (returnedObject, key) {\n\t returnedObject[key] = object[key];\n\t return returnedObject;\n\t }, returnedObject);\n\t }, initialObject);\n\t }\n\t};\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar utils = __webpack_require__(1);\n\t\n\tvar convertValidationsToObject = function convertValidationsToObject(validations) {\n\t\n\t if (typeof validations === 'string') {\n\t\n\t return validations.split(/\\,(?![^{\\[]*[}\\]])/g).reduce(function (validations, validation) {\n\t var args = validation.split(':');\n\t var validateMethod = args.shift();\n\t\n\t args = args.map(function (arg) {\n\t try {\n\t return JSON.parse(arg);\n\t } catch (e) {\n\t return arg; // It is a string if it can not parse it\n\t }\n\t });\n\t\n\t if (args.length > 1) {\n\t throw new Error('Formsy does not support multiple args on string validations. Use object format of validations instead.');\n\t }\n\t\n\t validations[validateMethod] = args.length ? args[0] : true;\n\t return validations;\n\t }, {});\n\t }\n\t\n\t return validations || {};\n\t};\n\t\n\tmodule.exports = {\n\t getInitialState: function getInitialState() {\n\t return {\n\t _value: this.props.value,\n\t _isRequired: false,\n\t _isValid: true,\n\t _isPristine: true,\n\t _pristineValue: this.props.value,\n\t _validationError: '',\n\t _externalError: null,\n\t _formSubmitted: false\n\t };\n\t },\n\t getDefaultProps: function getDefaultProps() {\n\t return {\n\t validationError: '',\n\t validationErrors: {}\n\t };\n\t },\n\t\n\t componentWillMount: function componentWillMount() {\n\t var configure = (function () {\n\t this.setValidations(this.props.validations, this.props.required);\n\t this.props._attachToForm(this);\n\t }).bind(this);\n\t\n\t if (!this.props.name) {\n\t throw new Error('Form Input requires a name property when used');\n\t }\n\t\n\t if (!this.props._attachToForm) {\n\t return setTimeout((function () {\n\t if (!this.isMounted()) return;\n\t if (!this.props._attachToForm) {\n\t throw new Error('Form Mixin requires component to be nested in a Form');\n\t }\n\t configure();\n\t }).bind(this), 0);\n\t }\n\t configure();\n\t },\n\t\n\t // We have to make the validate method is kept when new props are added\n\t componentWillReceiveProps: function componentWillReceiveProps(nextProps) {\n\t this.setValidations(nextProps.validations, nextProps.required);\n\t },\n\t\n\t componentDidUpdate: function componentDidUpdate(prevProps) {\n\t\n\t // If the value passed has changed, set it. If value is not passed it will\n\t // internally update, and this will never run\n\t if (!utils.isSame(this.props.value, prevProps.value)) {\n\t this.setValue(this.props.value);\n\t }\n\t },\n\t\n\t // Detach it when component unmounts\n\t componentWillUnmount: function componentWillUnmount() {\n\t this.props._detachFromForm(this);\n\t },\n\t\n\t setValidations: function setValidations(validations, required) {\n\t\n\t // Add validations to the store itself as the props object can not be modified\n\t this._validations = convertValidationsToObject(validations) || {};\n\t this._requiredValidations = required === true ? { isDefaultRequiredValue: true } : convertValidationsToObject(required);\n\t },\n\t\n\t // We validate after the value has been set\n\t setValue: function setValue(value) {\n\t this.setState({\n\t _value: value,\n\t _isPristine: false\n\t }, (function () {\n\t this.props._validate(this);\n\t }).bind(this));\n\t },\n\t resetValue: function resetValue() {\n\t this.setState({\n\t _value: this.state._pristineValue,\n\t _isPristine: true\n\t }, function () {\n\t this.props._validate(this);\n\t });\n\t },\n\t getValue: function getValue() {\n\t return this.state._value;\n\t },\n\t hasValue: function hasValue() {\n\t return this.state._value !== '';\n\t },\n\t getErrorMessage: function getErrorMessage() {\n\t return !this.isValid() || this.showRequired() ? this.state._externalError || this.state._validationError : null;\n\t },\n\t isFormDisabled: function isFormDisabled() {\n\t return this.props._isFormDisabled();\n\t },\n\t isValid: function isValid() {\n\t return this.state._isValid;\n\t },\n\t isPristine: function isPristine() {\n\t return this.state._isPristine;\n\t },\n\t isFormSubmitted: function isFormSubmitted() {\n\t return this.state._formSubmitted;\n\t },\n\t isRequired: function isRequired() {\n\t return !!this.props.required;\n\t },\n\t showRequired: function showRequired() {\n\t return this.state._isRequired;\n\t },\n\t showError: function showError() {\n\t return !this.showRequired() && !this.isValid();\n\t },\n\t isValidValue: function isValidValue(value) {\n\t return this.props._isValidValue.call(null, this, value);\n\t }\n\t};\n\n/***/ },\n/* 3 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar isExisty = function isExisty(value) {\n\t return value !== null && value !== undefined;\n\t};\n\t\n\tvar validations = {\n\t isDefaultRequiredValue: function isDefaultRequiredValue(values, value) {\n\t return value === undefined || value === '';\n\t },\n\t isExisty: (function (_isExisty) {\n\t function isExisty(_x, _x2) {\n\t return _isExisty.apply(this, arguments);\n\t }\n\t\n\t isExisty.toString = function () {\n\t return _isExisty.toString();\n\t };\n\t\n\t return isExisty;\n\t })(function (values, value) {\n\t return isExisty(value);\n\t }),\n\t matchRegexp: function matchRegexp(values, value, regexp) {\n\t return isExisty(value) && regexp.test(value);\n\t },\n\t isUndefined: function isUndefined(values, value) {\n\t return value === undefined;\n\t },\n\t isEmptyString: function isEmptyString(values, value) {\n\t return value === '';\n\t },\n\t isEmail: function isEmail(values, value) {\n\t return validations.matchRegexp(values, value, /^((([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);\n\t },\n\t isUrl: function isUrl(values, value) {\n\t return validations.matchRegexp(values, value, /^(https?|s?ftp):\\/\\/(((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:)*@)?(((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5]))|((([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])))\\.?)(:\\d*)?)(\\/((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)+(\\/(([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)*)*)?)?(\\?((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)|[\\uE000-\\uF8FF]|\\/|\\?)*)?(#((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)|\\/|\\?)*)?$/i);\n\t },\n\t isTrue: function isTrue(values, value) {\n\t return value === true;\n\t },\n\t isFalse: function isFalse(values, value) {\n\t return value === false;\n\t },\n\t isNumeric: function isNumeric(values, value) {\n\t if (!isExisty(value)) {\n\t return false;\n\t }\n\t if (typeof value === 'number') {\n\t return true;\n\t } else {\n\t var matchResults = value.match(/[-+]?(\\d*[.])?\\d+/);\n\t if (!!matchResults) {\n\t return matchResults[0] == value;\n\t } else {\n\t return false;\n\t }\n\t }\n\t },\n\t isAlpha: function isAlpha(values, value) {\n\t return value && /^[a-zA-Z]+$/.test(value);\n\t },\n\t isWords: function isWords(values, value) {\n\t return value && /^[a-zA-Z\\s]+$/.test(value);\n\t },\n\t isSpecialWords: function isSpecialWords(values, value) {\n\t return !value || /^[a-zA-Z\\s\\u00C0-\\u017F]+$/.test(value);\n\t },\n\t isLength: function isLength(values, value, length) {\n\t return isExisty(value) && value.length === length;\n\t },\n\t equals: function equals(values, value, eql) {\n\t return value == eql;\n\t },\n\t equalsField: function equalsField(values, value, field) {\n\t return value == values[field];\n\t },\n\t maxLength: function maxLength(values, value, length) {\n\t return isExisty(value) && value.length <= length;\n\t },\n\t minLength: function minLength(values, value, length) {\n\t return isExisty(value) && value.length >= length;\n\t }\n\t};\n\t\n\tmodule.exports = validations;\n\n/***/ },\n/* 4 */\n/***/ function(module, exports, __webpack_require__) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_4__;\n\n/***/ }\n/******/ ])\n});\n;\n\n\n/** WEBPACK FOOTER **\n ** formsy-react.js\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 646d477f5240abe57846\n **/","var React = global.React || require('react');\nvar Formsy = {};\nvar validationRules = require('./validationRules.js');\nvar utils = require('./utils.js');\nvar Mixin = require('./Mixin.js');\nvar options = {};\n\nFormsy.Mixin = Mixin;\n\nFormsy.defaults = function (passedOptions) {\n options = passedOptions;\n};\n\nFormsy.addValidationRule = function (name, func) {\n validationRules[name] = func;\n};\n\nFormsy.Form = React.createClass({\n getInitialState: function () {\n return {\n isValid: true,\n isSubmitting: false,\n canChange: false\n };\n },\n getDefaultProps: function () {\n return {\n onSuccess: function () {},\n onError: function () {},\n onSubmit: function () {},\n onValidSubmit: function () {},\n onInvalidSubmit: function () {},\n onSubmitted: function () {},\n onValid: function () {},\n onInvalid: function () {},\n onChange: function () {},\n validationErrors: null,\n preventExternalInvalidation: false\n };\n },\n\n // Add a map to store the inputs of the form, a model to store\n // the values of the form and register child inputs\n componentWillMount: function () {\n this.inputs = {};\n this.model = {};\n },\n\n componentDidMount: function () {\n this.validateForm();\n },\n\n componentWillUpdate: function () {\n\n // Keep a reference to input keys before form updates,\n // to check if inputs has changed after render\n this.prevInputKeys = Object.keys(this.inputs);\n\n },\n\n componentDidUpdate: function () {\n\n if (this.props.validationErrors) {\n this.setInputValidationErrors(this.props.validationErrors);\n }\n\n var newInputKeys = Object.keys(this.inputs);\n if (utils.arraysDiffer(this.prevInputKeys, newInputKeys)) {\n this.validateForm();\n }\n\n },\n\n // Allow resetting to specified data\n reset: function (data) {\n this.setFormPristine(true);\n this.resetModel(data);\n },\n\n // Update model, submit to url prop and send the model\n submit: function (event) {\n\n event && event.preventDefault();\n\n // Trigger form as not pristine.\n // If any inputs have not been touched yet this will make them dirty\n // so validation becomes visible (if based on isPristine)\n this.setFormPristine(false);\n this.updateModel();\n var model = this.mapModel();\n this.props.onSubmit(model, this.resetModel, this.updateInputsWithError);\n this.state.isValid ? this.props.onValidSubmit(model, this.resetModel, this.updateInputsWithError) : this.props.onInvalidSubmit(model, this.resetModel, this.updateInputsWithError);\n\n },\n\n mapModel: function () {\n if (this.props.mapping) {\n return this.props.mapping(this.model)\n } else {\n return Object.keys(this.model).reduce(function (mappedModel, key) {\n \n var keyArray = key.split('.');\n while (keyArray.length) {\n var currentKey = keyArray.shift();\n mappedModel[currentKey] = keyArray.length ? mappedModel[currentKey] || {} : this.model[key];\n }\n\n return mappedModel;\n\n }.bind(this), {});\n }\n },\n\n // Goes through all registered components and\n // updates the model values\n updateModel: function () {\n Object.keys(this.inputs).forEach(function (name) {\n var component = this.inputs[name];\n this.model[name] = component.state._value;\n }.bind(this));\n },\n\n // Reset each key in the model to the original / initial / specified value\n resetModel: function (data) {\n Object.keys(this.inputs).forEach(function (name) {\n if (data && data[name]) {\n this.inputs[name].setValue(data[name]);\n } else {\n this.inputs[name].resetValue();\n }\n }.bind(this));\n this.validateForm();\n },\n\n setInputValidationErrors: function (errors) {\n Object.keys(this.inputs).forEach(function (name, index) {\n var component = this.inputs[name];\n var args = [{\n _isValid: !(name in errors),\n _validationError: errors[name]\n }];\n component.setState.apply(component, args);\n }.bind(this));\n },\n\n // Checks if the values have changed from their initial value\n isChanged: function() {\n return !utils.isSame(this.getPristineValues(), this.getCurrentValues());\n },\n\n getPristineValues: function() {\n var inputs = this.inputs;\n return Object.keys(inputs).reduce(function (data, name) {\n var component = inputs[name];\n data[name] = component.props.value;\n return data;\n }, {});\n },\n\n // Go through errors from server and grab the components\n // stored in the inputs map. Change their state to invalid\n // and set the serverError message\n updateInputsWithError: function (errors) {\n Object.keys(errors).forEach(function (name, index) {\n var component = this.inputs[name];\n\n if (!component) {\n throw new Error('You are trying to update an input that does not exist. Verify errors object with input names. ' + JSON.stringify(errors));\n }\n var args = [{\n _isValid: this.props.preventExternalInvalidation || false,\n _externalError: errors[name]\n }];\n component.setState.apply(component, args);\n }.bind(this));\n },\n\n // Traverse the children and children of children to find\n // all inputs by checking the name prop. Maybe do a better\n // check here\n traverseChildrenAndRegisterInputs: function (children) {\n\n if (typeof children !== 'object' || children === null) {\n return children;\n }\n return React.Children.map(children, function (child) {\n\n if (typeof child !== 'object' || child === null) {\n return child;\n }\n\n if (child.props && child.props.name) {\n\n return React.cloneElement(child, {\n _attachToForm: this.attachToForm,\n _detachFromForm: this.detachFromForm,\n _validate: this.validate,\n _isFormDisabled: this.isFormDisabled,\n _isValidValue: function (component, value) {\n return this.runValidation(component, value).isValid;\n }.bind(this)\n }, child.props && child.props.children);\n } else {\n return React.cloneElement(child, {}, this.traverseChildrenAndRegisterInputs(child.props && child.props.children));\n }\n\n }, this);\n\n },\n\n isFormDisabled: function () {\n return this.props.disabled;\n },\n\n getCurrentValues: function () {\n return Object.keys(this.inputs).reduce(function (data, name) {\n var component = this.inputs[name];\n data[name] = component.state._value;\n return data;\n }.bind(this), {});\n },\n\n setFormPristine: function (isPristine) {\n var inputs = this.inputs;\n var inputKeys = Object.keys(inputs);\n\n this.setState({\n _formSubmitted: !isPristine\n })\n\n // Iterate through each component and set it as pristine\n // or \"dirty\".\n inputKeys.forEach(function (name, index) {\n var component = inputs[name];\n component.setState({\n _formSubmitted: !isPristine,\n _isPristine: isPristine\n });\n }.bind(this));\n },\n\n // Use the binded values and the actual input value to\n // validate the input and set its state. Then check the\n // state of the form itself\n validate: function (component) {\n\n // Trigger onChange\n if (this.state.canChange) {\n this.props.onChange(this.getCurrentValues(), this.isChanged());\n }\n\n var validation = this.runValidation(component);\n // Run through the validations, split them up and call\n // the validator IF there is a value or it is required\n component.setState({\n _isValid: validation.isValid,\n _isRequired: validation.isRequired,\n _validationError: validation.error,\n _externalError: null\n }, this.validateForm);\n\n },\n\n // Checks validation on current value or a passed value\n runValidation: function (component, value) {\n\n var currentValues = this.getCurrentValues();\n var validationErrors = component.props.validationErrors;\n var validationError = component.props.validationError;\n value = arguments.length === 2 ? value : component.state._value;\n\n var validationResults = this.runRules(value, currentValues, component._validations);\n var requiredResults = this.runRules(value, currentValues, component._requiredValidations);\n\n // the component defines an explicit validate function\n if (typeof component.validate === \"function\") {\n validationResults.failed = component.validate() ? [] : ['failed'];\n }\n\n var isRequired = Object.keys(component._requiredValidations).length ? !!requiredResults.success.length : false;\n var isValid = !validationResults.failed.length && !(this.props.validationErrors && this.props.validationErrors[component.props.name]);\n\n return {\n isRequired: isRequired,\n isValid: isRequired ? false : isValid,\n error: (function () {\n\n if (isValid && !isRequired) {\n return '';\n }\n\n if (validationResults.errors.length) {\n return validationResults.errors[0];\n }\n\n if (this.props.validationErrors && this.props.validationErrors[component.props.name]) {\n return this.props.validationErrors[component.props.name];\n }\n\n if (isRequired) {\n return validationErrors[requiredResults.success[0]] || null;\n }\n\n if (!isValid) {\n return validationErrors[validationResults.failed[0]] || validationError;\n }\n\n }.call(this))\n };\n\n },\n\n runRules: function (value, currentValues, validations) {\n\n var results = {\n errors: [],\n failed: [],\n success: []\n };\n if (Object.keys(validations).length) {\n Object.keys(validations).forEach(function (validationMethod) {\n\n if (validationRules[validationMethod] && typeof validations[validationMethod] === 'function') {\n throw new Error('Formsy does not allow you to override default validations: ' + validationMethod);\n }\n\n if (!validationRules[validationMethod] && typeof validations[validationMethod] !== 'function') {\n throw new Error('Formsy does not have the validation rule: ' + validationMethod);\n }\n\n if (typeof validations[validationMethod] === 'function') {\n var validation = validations[validationMethod](currentValues, value);\n if (typeof validation === 'string') {\n results.errors.push(validation);\n results.failed.push(validationMethod);\n } else if (!validation) {\n results.failed.push(validationMethod);\n }\n return;\n\n } else if (typeof validations[validationMethod] !== 'function') {\n var validation = validationRules[validationMethod](currentValues, value, validations[validationMethod]);\n if (typeof validation === 'string') {\n results.errors.push(validation);\n results.failed.push(validationMethod);\n } else if (!validation) {\n results.failed.push(validationMethod);\n } else {\n results.success.push(validationMethod);\n }\n return;\n\n }\n\n return results.success.push(validationMethod);\n\n });\n }\n\n return results;\n\n },\n\n // Validate the form by going through all child input components\n // and check their state\n validateForm: function () {\n var allIsValid = true;\n var inputs = this.inputs;\n var inputKeys = Object.keys(inputs);\n\n // We need a callback as we are validating all inputs again. This will\n // run when the last component has set its state\n var onValidationComplete = function () {\n inputKeys.forEach(function (name) {\n if (!inputs[name].state._isValid) {\n allIsValid = false;\n }\n }.bind(this));\n\n this.setState({\n isValid: allIsValid\n });\n\n if (allIsValid) {\n this.props.onValid();\n } else {\n this.props.onInvalid();\n }\n\n // Tell the form that it can start to trigger change events\n this.setState({\n canChange: true\n });\n\n }.bind(this);\n\n // Run validation again in case affected by other inputs. The\n // last component validated will run the onValidationComplete callback\n inputKeys.forEach(function (name, index) {\n var component = inputs[name];\n var validation = this.runValidation(component);\n if (validation.isValid && component.state._externalError) {\n validation.isValid = false;\n }\n component.setState({\n _isValid: validation.isValid,\n _isRequired: validation.isRequired,\n _validationError: validation.error,\n _externalError: !validation.isValid && component.state._externalError ? component.state._externalError : null\n }, index === inputKeys.length - 1 ? onValidationComplete : null);\n }.bind(this));\n\n // If there are no inputs, set state where form is ready to trigger\n // change event. New inputs might be added later\n if (!inputKeys.length && this.isMounted()) {\n this.setState({\n canChange: true\n });\n }\n },\n\n // Method put on each input component to register\n // itself to the form\n attachToForm: function (component) {\n this.inputs[component.props.name] = component;\n this.model[component.props.name] = component.state._value;\n this.validate(component);\n },\n\n // Method put on each input component to unregister\n // itself from the form\n detachFromForm: function (component) {\n delete this.inputs[component.props.name];\n delete this.model[component.props.name];\n },\n render: function () {\n\n return React.DOM.form(utils.extend({}, this.props, {\n onSubmit: this.submit,\n className: this.props.className\n }),\n this.traverseChildrenAndRegisterInputs(this.props.children)\n );\n\n }\n});\n\nif (!global.exports && !global.module && (!global.define || !global.define.amd)) {\n global.Formsy = Formsy;\n}\n\nmodule.exports = Formsy;\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/main.js\n **/","module.exports = {\n arraysDiffer: function (a, b) {\n var isDifferent = false;\n if (a.length !== b.length) {\n isDifferent = true;\n } else {\n a.forEach(function (item, index) {\n if (!this.isSame(item, b[index])) {\n isDifferent = true;\n }\n }, this);\n }\n return isDifferent;\n },\n\n objectsDiffer: function (a, b) {\n var isDifferent = false;\n if (Object.keys(a).length !== Object.keys(b).length) {\n isDifferent = true;\n } else {\n Object.keys(a).forEach(function (key) {\n if (!this.isSame(a[key], b[key])) {\n isDifferent = true;\n }\n }, this);\n }\n return isDifferent;\n },\n\n isSame: function (a, b) {\n if (typeof a !== typeof b) {\n return false;\n } else if (Array.isArray(a)) {\n return !this.arraysDiffer(a, b);\n } else if (typeof a === 'object' && a !== null && b !== null) {\n return !this.objectsDiffer(a, b);\n }\n\n return a === b;\n },\n extend: function () {\n var objects = [].slice.call(arguments);\n var initialObject = objects.shift();\n return objects.reduce(function (returnedObject, object) {\n return Object.keys(object).reduce(function (returnedObject, key) {\n returnedObject[key] = object[key];\n return returnedObject;\n }, returnedObject);\n }, initialObject);\n }\n};\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/utils.js\n **/","var utils = require('./utils.js');\n\nvar convertValidationsToObject = function (validations) {\n\n if (typeof validations === 'string') {\n\n return validations.split(/\\,(?![^{\\[]*[}\\]])/g).reduce(function (validations, validation) {\n var args = validation.split(':');\n var validateMethod = args.shift();\n\n args = args.map(function (arg) {\n try {\n return JSON.parse(arg);\n } catch (e) {\n return arg; // It is a string if it can not parse it\n }\n });\n\n if (args.length > 1) {\n throw new Error('Formsy does not support multiple args on string validations. Use object format of validations instead.');\n }\n\n validations[validateMethod] = args.length ? args[0] : true;\n return validations;\n }, {});\n\n }\n\n return validations || {};\n};\n\nmodule.exports = {\n getInitialState: function () {\n return {\n _value: this.props.value,\n _isRequired: false,\n _isValid: true,\n _isPristine: true,\n _pristineValue: this.props.value,\n _validationError: '',\n _externalError: null,\n _formSubmitted: false\n };\n },\n getDefaultProps: function () {\n return {\n validationError: '',\n validationErrors: {}\n };\n },\n\n componentWillMount: function () {\n var configure = function () {\n this.setValidations(this.props.validations, this.props.required);\n this.props._attachToForm(this);\n }.bind(this);\n\n if (!this.props.name) {\n throw new Error('Form Input requires a name property when used');\n }\n\n if (!this.props._attachToForm) {\n return setTimeout(function () {\n if (!this.isMounted()) return;\n if (!this.props._attachToForm) {\n throw new Error('Form Mixin requires component to be nested in a Form');\n }\n configure();\n }.bind(this), 0);\n }\n configure();\n },\n\n // We have to make the validate method is kept when new props are added\n componentWillReceiveProps: function (nextProps) {\n this.setValidations(nextProps.validations, nextProps.required);\n },\n\n componentDidUpdate: function (prevProps) {\n\n // If the value passed has changed, set it. If value is not passed it will\n // internally update, and this will never run\n if (!utils.isSame(this.props.value, prevProps.value)) {\n this.setValue(this.props.value);\n }\n },\n\n // Detach it when component unmounts\n componentWillUnmount: function () {\n this.props._detachFromForm(this);\n },\n\n setValidations: function (validations, required) {\n\n // Add validations to the store itself as the props object can not be modified\n this._validations = convertValidationsToObject(validations) || {};\n this._requiredValidations = required === true ? {isDefaultRequiredValue: true} : convertValidationsToObject(required);\n\n },\n\n // We validate after the value has been set\n setValue: function (value) {\n this.setState({\n _value: value,\n _isPristine: false\n }, function () {\n this.props._validate(this);\n }.bind(this));\n },\n resetValue: function () {\n this.setState({\n _value: this.state._pristineValue,\n _isPristine: true\n }, function () {\n this.props._validate(this);\n });\n },\n getValue: function () {\n return this.state._value;\n },\n hasValue: function () {\n return this.state._value !== '';\n },\n getErrorMessage: function () {\n return !this.isValid() || this.showRequired() ? (this.state._externalError || this.state._validationError) : null;\n },\n isFormDisabled: function () {\n return this.props._isFormDisabled();\n },\n isValid: function () {\n return this.state._isValid;\n },\n isPristine: function () {\n return this.state._isPristine;\n },\n isFormSubmitted: function () {\n return this.state._formSubmitted;\n },\n isRequired: function () {\n return !!this.props.required;\n },\n showRequired: function () {\n return this.state._isRequired;\n },\n showError: function () {\n return !this.showRequired() && !this.isValid();\n },\n isValidValue: function (value) {\n return this.props._isValidValue.call(null, this, value);\n }\n};\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/Mixin.js\n **/","var isExisty = function (value) {\n return value !== null && value !== undefined;\n};\n\nvar validations = {\n isDefaultRequiredValue: function (values, value) {\n return value === undefined || value === '';\n },\n isExisty: function (values, value) {\n return isExisty(value);\n },\n matchRegexp: function (values, value, regexp) {\n return isExisty(value) && regexp.test(value);\n },\n isUndefined: function (values, value) {\n return value === undefined;\n },\n isEmptyString: function (values, value) {\n return value === '';\n },\n isEmail: function (values, value) {\n return validations.matchRegexp(values, value, /^((([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);\n },\n isUrl: function (values, value) {\n return validations.matchRegexp(values, value, /^(https?|s?ftp):\\/\\/(((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:)*@)?(((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5]))|((([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])))\\.?)(:\\d*)?)(\\/((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)+(\\/(([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)*)*)?)?(\\?((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)|[\\uE000-\\uF8FF]|\\/|\\?)*)?(#((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)|\\/|\\?)*)?$/i);\n },\n isTrue: function (values, value) {\n return value === true;\n },\n isFalse: function (values, value) {\n return value === false;\n },\n isNumeric: function (values, value) {\n if (!isExisty(value)) {\n return false;\n }\n if (typeof value === 'number') {\n return true;\n } else {\n var matchResults = value.match(/[-+]?(\\d*[.])?\\d+/);\n if (!!matchResults) {\n return matchResults[0] == value;\n } else {\n return false;\n }\n }\n },\n isAlpha: function (values, value) {\n return value && /^[a-zA-Z]+$/.test(value);\n },\n isWords: function (values, value) {\n return value && /^[a-zA-Z\\s]+$/.test(value);\n },\n isSpecialWords: function (values, value) {\n return !value || /^[a-zA-Z\\s\\u00C0-\\u017F]+$/.test(value);\n },\n isLength: function (values, value, length) {\n return isExisty(value) && value.length === length;\n },\n equals: function (values, value, eql) {\n return value == eql;\n },\n equalsField: function (values, value, field) {\n return value == values[field];\n },\n maxLength: function (values, value, length) {\n return isExisty(value) && value.length <= length;\n },\n minLength: function (values, value, length) {\n return isExisty(value) && value.length >= length;\n }\n};\n\nmodule.exports = validations;\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/validationRules.js\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_4__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"react\"\n ** module id = 4\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file