Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-nested-validation

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-nested-validation - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

192

dist/index.js

@@ -1,1 +0,191 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports["react-nested-validation"]=t(require("react")):e["react-nested-validation"]=t(e.react)}(window,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}({0:function(e,t,r){e.exports=r("tjUo")},Al62:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.isNil=function(e){return void 0===e||null===e||""===e},t.isFunc=function(e){return"function"==typeof e},t.capitalize=function(e){return""+e[0].toUpperCase()+e.slice(1)}},"D+7e":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,a=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,a=!1,i=void 0;try{for(var o,u=e[Symbol.iterator]();!(n=(o=u.next()).done)&&(r.push(o.value),!t||r.length!==t);n=!0);}catch(e){a=!0,i=e}finally{try{!n&&u.return&&u.return()}finally{if(a)throw i}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),u=r("pR90"),s=(n=u)&&n.__esModule?n:{default:n};function l(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}var f=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.errors=s.default.normalizeErrors()}return o(e,[{key:"addFieldError",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:s.default.ERROR,n=this.errors.fields[e]||[];n.push({type:r,message:t}),this.errors.fields[e]=n,this.updateCounts(r)}},{key:"addFormError",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s.default.ERROR,r=this.errors.form||[];r.push({type:t,message:e}),this.errors.form=r,this.updateCounts(t)}},{key:"updateCounts",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.errors.counts[e]=(this.errors.counts[e]||0)+t}}],[{key:"merge",value:function(e,t){return{fields:i({},e.fields,t.fields),form:[].concat(l(e.form),l(t.form)),counts:this._mergeCounts(e.counts,t.counts)}}},{key:"_mergeCounts",value:function(e,t){var r=i({},e),n=!0,o=!1,u=void 0;try{for(var s,l=Object.entries(t)[Symbol.iterator]();!(n=(s=l.next()).done);n=!0){var f=s.value,c=a(f,2),v=c[0],d=c[1];r[v]=(r[v]||0)+d}}catch(e){o=!0,u=e}finally{try{!n&&l.return&&l.return()}finally{if(o)throw u}}return r}}]),e}();t.default=f},JE77:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},a=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=s(r("cDcd")),o=r("Al62"),u=s(r("yK9j"));function s(e){return e&&e.__esModule?e:{default:e}}function l(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}t.default=function(e){return function(t){var r,s,c,v=e.initialPage,d=function(e,t){var r={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r}(e,["initialPage"]);return(0,u.default)(d)((c=s=function(e){function r(){var e,t,a;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r);for(var i=arguments.length,u=Array(i),s=0;s<i;s++)u[s]=arguments[s];return t=a=f(this,(e=r.__proto__||Object.getPrototypeOf(r)).call.apply(e,[this].concat(u))),a.state={page:(0,o.isFunc)(v)?v(a.props):v,history:[],visited:{}},a.nextPage=function(e,t,r){var i=a.state,u=i.page,s=i.visited;e&&e.validate(!0);var f=!s[u];e&&(e.state.errors.counts.error>0||e.state.errors.counts.warning>0&&f)?(r&&r(u,e),a.setState({visited:n({},s,l({},u,!0))})):(0,o.isFunc)(t)?t():a.setState({page:t,visited:n({},s,l({},u,!0)),history:[].concat(function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}(a.state.history),[u])})},a.previousPage=function(){var e=a.state.history;e.length>0&&a.setState({page:e[e.length-1],history:e.slice(0,e.length-1)})},a.renderPage=function(e){var t=a.state.page;return e["render"+(0,o.capitalize)(t)]()},f(a,t)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(r,i.default.Component),a(r,[{key:"render",value:function(){return i.default.createElement(t,n({},this.props,{nextPage:this.nextPage,previousPage:this.previousPage,finishWizard:this.finishWizard,renderPage:this.renderPage}))}}]),r}(),s.Form=e.form,r=c))||r}}},cDcd:function(t,r){t.exports=e},pR90:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,a,i,o=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,a=!1,i=void 0;try{for(var o,u=e[Symbol.iterator]();!(n=(o=u.next()).done)&&(r.push(o.value),!t||r.length!==t);n=!0);}catch(e){a=!0,i=e}finally{try{!n&&u.return&&u.return()}finally{if(a)throw i}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),u=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},l=r("D+7e"),f=(i=l)&&i.__esModule?i:{default:i},c=r("Al62");function v(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function h(e,t,r){var n=new e(t=s({},t,{values:s({},t.values||{},r)}));return n.validate(),n.state}var y=(a=n=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.state=e.normalize(t),this.nested={},this.fieldValidators={},this.defaultValues={}}return u(e,[{key:"parse",value:function(e,t){var r=this,n=e;if(Array.isArray(this.nested))e=(e||[]).map(function(e){return(new r.nested[0]).parse(e,t)}),e=[].concat(d(this.state.values||[]),d(e));else{e=e||{};var a=void 0;if(this.fields){a={};var i=!0,u=!1,l=void 0;try{for(var f,v=this.fields[Symbol.iterator]();!(i=(f=v.next()).done);i=!0){var h=f.value;a[h]=e[h]}}catch(e){u=!0,l=e}finally{try{!i&&v.return&&v.return()}finally{if(u)throw l}}}else a=s({},e);if(this.nested){var y=!0,p=!1,m=void 0;try{for(var b,g=Object.entries(this.nested)[Symbol.iterator]();!(y=(b=g.next()).done);y=!0){var w=b.value,O=o(w,2),j=O[0],_=O[1],k=void 0,A=this["initial"+(0,c.capitalize)(j)];k=A?A(e,j):e;var x=new _;a[j]=x.parse(k,t)}}catch(e){p=!0,m=e}finally{try{!y&&g.return&&g.return()}finally{if(p)throw m}}}e=s({},this.state.values||{},a)}return this.parseValues&&(e=this.parseValues(e)),this.state=s({},this.state,{values:e,touched:{},initial:n}),this.render(),this.validate(t),this.state}},{key:"render",value:function(){var e=this.state.values,t=void 0;if(Array.isArray(this.nested))t=e.map(function(e){return e.flat});else{if(this.fields){t={};var r=!0,n=!1,a=void 0;try{for(var i,o=this.fields[Symbol.iterator]();!(r=(i=o.next()).done);r=!0){var u=i.value;t[u]=e[u]}}catch(e){n=!0,a=e}finally{try{!r&&o.return&&o.return()}finally{if(n)throw a}}}else t=s({},e);var l=!0,f=!1,v=void 0;try{for(var d,h=Object.keys(this.nested)[Symbol.iterator]();!(l=(d=h.next()).done);l=!0){var y=d.value,p=this["render"+(0,c.capitalize)(y)],m=this.state.values[y].flat;p?t=p(t,m):Array.isArray(m)?t[y]=m:t=s({},t,m)}}catch(e){f=!0,v=e}finally{try{!l&&h.return&&h.return()}finally{if(f)throw v}}}return this.state.flat=this.renderValues(t),t}},{key:"renderValues",value:function(e){return e}},{key:"validate",value:function(e){this.forceValidation=e;var t=new f.default,r=this.getValues();if(e){if(Array.isArray(r)){var n=this.nested[0];r=r.map(function(t){var r=new n(t);return r.validate(e),r.state})}else{var a=!0,i=!1,u=void 0;try{for(var l,c=Object.entries(this.nested)[Symbol.iterator]();!(a=(l=c.next()).done);a=!0){var v=l.value,d=o(v,2),h=d[0],y=d[1];if(void 0!==r[h]){var p=new y(r[h]);p.validate(e),r[h]=p.state}}}catch(e){i=!0,u=e}finally{try{!a&&c.return&&c.return()}finally{if(i)throw u}}}this.state=s({},this.state,{values:r})}if(this.validateFields(t),this.validateForm(t),Array.isArray(r)){var m=!0,b=!1,g=void 0;try{for(var w,O=r[Symbol.iterator]();!(m=(w=O.next()).done);m=!0){var j=w.value.errors,_=void 0===j?{}:j,k=!0,A=!1,x=void 0;try{for(var P,F=Object.entries(_.counts||{})[Symbol.iterator]();!(k=(P=F.next()).done);k=!0){var S=P.value,E=o(S,2),C=E[0],R=E[1];t.updateCounts(C,R)}}catch(e){A=!0,x=e}finally{try{!k&&F.return&&F.return()}finally{if(A)throw x}}}}catch(e){b=!0,g=e}finally{try{!m&&O.return&&O.return()}finally{if(b)throw g}}}else{var V=!0,M=!1,T=void 0;try{for(var z,I=Object.keys(this.nested)[Symbol.iterator]();!(V=(z=I.next()).done);V=!0){var N=(r[z.value]||{}).errors,U=void 0===N?{}:N,W=!0,q=!1,D=void 0;try{for(var G,J=Object.entries(U.counts||{})[Symbol.iterator]();!(W=(G=J.next()).done);W=!0){var K=G.value,L=o(K,2),B=L[0],H=L[1];t.updateCounts(B,H)}}catch(e){q=!0,D=e}finally{try{!W&&J.return&&J.return()}finally{if(q)throw D}}}}catch(e){M=!0,T=e}finally{try{!V&&I.return&&I.return()}finally{if(M)throw T}}}return this.state=s({},this.state,{errors:t.errors}),this.state}},{key:"validateFields",value:function(e){var t=!0,r=!1,n=void 0;try{for(var a,i=this.iterFieldValidators()[Symbol.iterator]();!(t=(a=i.next()).done);t=!0){var u=a.value,s=o(u,2),l=s[0],f=s[1];this.isTouched(l)&&f(e,l,this)}}catch(e){r=!0,n=e}finally{try{!t&&i.return&&i.return()}finally{if(r)throw n}}}},{key:"validateForm",value:function(e){}},{key:"iterFieldValidators",value:regeneratorRuntime.mark(function e(){var t,r,n,a,i,u,s,l,f,c,v,d,h,y,p;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=!0,r=!1,n=void 0,e.prev=3,a=Object.entries(this.fieldValidators)[Symbol.iterator]();case 5:if(t=(i=a.next()).done){e.next=39;break}u=i.value,s=o(u,2),l=s[0],f=s[1],c=!0,v=!1,d=void 0,e.prev=13,h=f[Symbol.iterator]();case 15:if(c=(y=h.next()).done){e.next=22;break}return p=y.value,e.next=19,[l,p];case 19:c=!0,e.next=15;break;case 22:e.next=28;break;case 24:e.prev=24,e.t0=e.catch(13),v=!0,d=e.t0;case 28:e.prev=28,e.prev=29,!c&&h.return&&h.return();case 31:if(e.prev=31,!v){e.next=34;break}throw d;case 34:return e.finish(31);case 35:return e.finish(28);case 36:t=!0,e.next=5;break;case 39:e.next=45;break;case 41:e.prev=41,e.t1=e.catch(3),r=!0,n=e.t1;case 45:e.prev=45,e.prev=46,!t&&a.return&&a.return();case 48:if(e.prev=48,!r){e.next=51;break}throw n;case 51:return e.finish(48);case 52:return e.finish(45);case 53:case"end":return e.stop()}},e,this,[[3,41,45,53],[13,24,28,36],[29,,31,35],[46,,48,52]])})},{key:"updateIn",value:function(e,t){if(void 0===t?t=[]:Array.isArray(t)||(t=t.split(".")),t.length>0){var r=void 0,n=void 0;if(Array.isArray(this.nested))r=parseInt(t[0]),n=new(0,this.nested[0])(this.state.values[r]);else r=t[0],n=new(0,this.nested[r])(this.state.values[r]);n.updateIn(e,t.slice(1)),this.updateValue(r,n.state)}else if(Array.isArray(this.nested)&&Array.isArray(e)){var a=!0,i=!1,u=void 0;try{for(var s,l=e[Symbol.iterator]();!(a=(s=l.next()).done);a=!0){var f=s.value;this.updateValue(null,f)}}catch(e){i=!0,u=e}finally{try{!a&&l.return&&l.return()}finally{if(i)throw u}}}else{var c=!0,d=!1,h=void 0;try{for(var y,p=Object.entries(e)[Symbol.iterator]();!(c=(y=p.next()).done);c=!0){var m=y.value,b=o(m,2),g=b[0],w=b[1];if(g.includes(".")){var O=g.split(".");this.updateIn(v({},O[O.length-1],w),O.slice(0,O.length-1))}else this.updateValue(g,w)}}catch(e){d=!0,h=e}finally{try{!c&&p.return&&p.return()}finally{if(d)throw h}}}this.render()}},{key:"updateValue",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.getValues(),a=this.state.touched;if(Array.isArray(n)){var i=this.nested[0],o=void 0;o=Array.isArray(e)?e:[e];var u=!0,l=!1,f=void 0;try{for(var c,y=o[Symbol.iterator]();!(u=(c=y.next()).done);u=!0){var p=c.value;if(null===p){var m=new i;m.parse(t),n=[].concat(d(n),[m.state])}else(p=parseInt(p))>=0&&p<n.length&&(n=[].concat(d(n.slice(0,p)),[r.merge?h(this.nested[0],n[p],t):t],d(n.slice(p+1))))}}catch(e){l=!0,f=e}finally{try{!u&&y.return&&y.return()}finally{if(l)throw f}}n=n.filter(function(e){return null!==e})}else n=s({},n,v({},e,t)),a=this.updateTouched(e,t,this.state.touched);this.state=s({},this.state,{values:n,touched:a}),this.state.errors=this.validate()}},{key:"updateTouched",value:function(e,t,r){var n=this.getInitial();return r=this.getTouched(r),s({},r,v({},e,!(!r[e]&&!t&&n[e]==t)))}},{key:"isTouched",value:function(e,t){var r=this.lookupForm(e),n=o(r,2),a=n[0],i=n[1];return this.forceValidation&&(a.touched[i]=!0),a.touched[i]||!1}},{key:"getTouched",value:function(e){return this._getState(e,"touched",{})}},{key:"getInitial",value:function(e){return this._getState(e,"initial",{})}},{key:"getValues",value:function(e){return this._getState(e,"values",this.defaultValues)}},{key:"getValue",value:function(e){var t=this.lookupForm(e),r=o(t,2),n=r[0],a=r[1];return e?n.values[a]:n.values}},{key:"lookupForm",value:function(e){var t=this.state;if(e){var r=e.split("."),n=!0,a=!1,i=void 0;try{for(var o,u=r.slice(0,r.length-1)[Symbol.iterator]();!(n=(o=u.next()).done);n=!0){var s=o.value;t=t.values[s]}}catch(e){a=!0,i=e}finally{try{!n&&u.return&&u.return()}finally{if(a)throw i}}e=r[r.length-1]}return[t,e]}},{key:"_getState",value:function(e,t,r){return void 0===e&&(e=this.state[t]||r),e}}]),e}(),n.ERROR="error",n.WARNING="warning",n.normalizeErrors=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s({fields:{},form:[],counts:{}},e)},n.normalize=function(e){return s({touched:{},errors:y.normalizeErrors(),values:{}},e)},a);t.default=y},qgJu:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.emptyWarning=t.required=void 0;var n,a=r("pR90"),i=(n=a)&&n.__esModule?n:{default:n},o=r("Al62");var u=function(e,t,r,n,a,i){var u=r.getValue(t);(0,o.isNil)(u)&&e.addFieldError(t,function(e,t,r,n){return e instanceof Function?e(t,r):e||n}(n,t,r,i),a)};(t.required=function e(t){return function(r,n,a){return u(r,n,a,t,i.default.ERROR,e.DEFAULT_MESSAGE)}}).DEFAULT_MESSAGE="This field is required.";t.emptyWarning=function(e){return function(t,r,n){return u(t,r,n,e,i.default.WARNING)}}},tjUo:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Form=t.asFormWizard=t.asForm=void 0;var n=r("qgJu");Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}})});var a=u(r("yK9j")),i=u(r("JE77")),o=u(r("pR90"));function u(e){return e&&e.__esModule?e:{default:e}}t.asForm=a.default,t.asFormWizard=i.default,t.Form=o.default},yK9j:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},a=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=s(r("cDcd")),o=s(r("pR90")),u=r("Al62");function s(e){return e&&e.__esModule?e:{default:e}}t.default=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t){var r,s;return s=r=function(r){function s(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,t));if(r.getFormClass=function(){return r.props.Form||e.form},r.makeForm=function(e){var t=new(r.getFormClass())(r.getFormState());return e&&t.validate(!0),t},r.getFormState=function(){var e=r.props.form,t=void 0===e?{}:e;(t||{}).values||(t=(new(r.getFormClass())).parse(r.props.initial));return o.default.normalize(n({},t))},r.handleChange2=function(e,t){var n=r.props,a=n.onChange,i=n.formPrefix;if((0,u.isNil)(i)){var o=r.makeForm();o.updateIn(e,t),o.state,a&&a({state:o.state,values:o.flat,payload:e,path:t})}else t=(0,u.isNil)(t)?i:i+"."+t,a&&a(e,t)},r.handleChange=function(e,t,n){var a=r.makeForm();a.updateValue(e,t,n);var i=r.props,o=i.onChange,s=i.formPrefix;o&&((0,u.isNil)(s)?o(a.state,e,t):o(s,a.state))},r.validate=function(e){var t=r.makeForm().validate();r.setState({errors:t})},!t.form){var a=r.makeForm();t.onChange&&t.onChange({state:a.state})}return r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(s,i.default.Component),a(s,[{key:"shouldComponentUpdate",value:function(e){return(e.form||{}).values!=(this.props.form||{}).values||(e.form||{}).errors!=(this.props.form||{}).errors||this.props.shouldUpdate&&this.props.shouldUpdate(e,this.props)}},{key:"render",value:function(){var e=this.props,r=e.form,a=(e.Form,function(e,t){var r={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r}(e,["form","Form"]));return(0,u.isNil)(r)&&(r=this.makeForm(this.props.forceValidation).state),i.default.createElement(t,n({},a,{form:r,onChange:this.handleChange2}))}}]),s}(),r.Form=e.form,s}}}})});
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"));
else if(typeof define === 'function' && define.amd)
define(["react"], factory);
else if(typeof exports === 'object')
exports["react-nested-validation"] = factory(require("react"));
else
root["react-nested-validation"] = factory(root["react"]);
})(window, function(__WEBPACK_EXTERNAL_MODULE_react__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ({
/***/ "./src/ErrorSet.js":
/*!*************************!*\
!*** ./src/ErrorSet.js ***!
\*************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = undefined;\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _Form = __webpack_require__(/*! ./Form */ \"./src/Form.js\");\n\nvar _Form2 = _interopRequireDefault(_Form);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n/**\n * Manages tracking of errors during validation.\n */\nvar ErrorSet = function () {\n function ErrorSet() {\n _classCallCheck(this, ErrorSet);\n\n this.errors = _Form2.default.normalizeErrors();\n }\n\n _createClass(ErrorSet, [{\n key: 'addFieldError',\n\n\n /**\n * Add an error to a form field.\n *\n * @param {string} field The field to add an error to.\n * @param {string} message The error message.\n * @param {string} type The type of error.\n */\n value: function addFieldError(field, message) {\n var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _Form2.default.ERROR;\n\n var fieldErrors = this.errors.fields[field] || [];\n fieldErrors.push({ type: type, message: message });\n this.errors.fields[field] = fieldErrors;\n this.updateCounts(type);\n }\n\n /**\n * Add a form level error.\n *\n * @param {string} message The error message.\n * @param {string} type The type of error.\n */\n\n }, {\n key: 'addFormError',\n value: function addFormError(message) {\n var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _Form2.default.ERROR;\n\n var formErrors = this.errors.form || [];\n formErrors.push({ type: type, message: message });\n this.errors.form = formErrors;\n this.updateCounts(type);\n }\n }, {\n key: 'updateCounts',\n value: function updateCounts(type) {\n var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;\n\n this.errors.counts[type] = (this.errors.counts[type] || 0) + count;\n }\n }], [{\n key: 'merge',\n value: function merge(a, b) {\n return {\n fields: _extends({}, a.fields, b.fields),\n form: [].concat(_toConsumableArray(a.form), _toConsumableArray(b.form)),\n counts: this._mergeCounts(a.counts, b.counts)\n };\n }\n }, {\n key: '_mergeCounts',\n value: function _mergeCounts(a, b) {\n var newCounts = _extends({}, a);\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = Object.entries(b)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var _ref = _step.value;\n\n var _ref2 = _slicedToArray(_ref, 2);\n\n var type = _ref2[0];\n var value = _ref2[1];\n\n newCounts[type] = (newCounts[type] || 0) + value;\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return newCounts;\n }\n }]);\n\n return ErrorSet;\n}();\n\nexports.default = ErrorSet;\n\n//# sourceURL=webpack://react-nested-validation/./src/ErrorSet.js?");
/***/ }),
/***/ "./src/Form.js":
/*!*********************!*\
!*** ./src/Form.js ***!
\*********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = undefined;\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _class, _temp;\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nvar _ErrorSet = __webpack_require__(/*! ./ErrorSet */ \"./src/ErrorSet.js\");\n\nvar _ErrorSet2 = _interopRequireDefault(_ErrorSet);\n\nvar _utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n/**\n * Merge an object of values into a form.\n *\n * TODO: This should live elsewhere.\n */\nfunction mergeValues(Form, state, values) {\n state = _extends({}, state, {\n values: _extends({}, state.values || {}, values)\n });\n var form = new Form(state);\n form.validate();\n return form.state;\n}\n\n/**\n * Base class for creating new forms. A form is responsible for data\n * initialisation and validation. Forms may be used hierarchically, in both\n * objects and lists.\n */\nvar Form = (_temp = _class = function () {\n\n /**\n * Construct a new form object.\n *\n * @param {object} state The form state.\n */\n\n\n /**\n * Ensure an errors object has all standard fields.\n */\n function Form() {\n var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n _classCallCheck(this, Form);\n\n this.state = Form.normalize(state);\n\n // Define any subforms. Fields can contain references to other forms for\n // directi subforms, but can also refer to an array with a single form type\n // element. This indicates an array of subforms.\n this.nested = {};\n\n // Define validators for each field of the form.\n this.fieldValidators = {};\n\n // The default values to be returned should no other values exist.\n this.defaultValues = {};\n }\n\n /**\n * Reconstruct incoming form values into a hierarchical representation. Forms\n * may have subforms as specified in the `fields` member. When initialising a\n * form it's convenient to specify just the values part of the initial data,\n * not with all the `touched` and `errors` fields. `parse` reorganises the\n * data into normal form.\n *\n * @param {(object|array)} values Initial form data.\n * @param {bool} forceValidation Force initial form validation.\n */\n\n\n /**\n * Ensure a form state object has all standard fields. Form state objects\n * need to have `touched`, `errors`, and `values` fields.\n */\n\n\n _createClass(Form, [{\n key: 'parse',\n value: function parse(values, forceValidation) {\n var _this = this;\n\n var initial = values;\n if (Array.isArray(this.nested)) {\n values = (values || []).map(function (x) {\n var sub = new _this.nested[0]();\n return sub.parse(x, forceValidation);\n });\n var stateValues = Array.isArray(this.state.values) ? this.state.values : [];\n values = [].concat(_toConsumableArray(stateValues || []), _toConsumableArray(values));\n } else {\n values = values || {};\n var newValues = void 0;\n\n // If we've been given a set of fields to copy, use them.\n // Otherwise use all available fields.\n if (this.fields) {\n newValues = {};\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = this.fields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var fldName = _step.value;\n\n newValues[fldName] = values[fldName];\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n } else {\n newValues = _extends({}, values);\n }\n\n if (this.nested) {\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = Object.entries(this.nested)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var _ref = _step2.value;\n\n var _ref2 = _slicedToArray(_ref, 2);\n\n var _fldName = _ref2[0];\n var Sub = _ref2[1];\n\n\n // Check for a nested parser and use that if it exists. If\n // not, use the same flat values.\n var subValues = void 0;\n var func = this['initial' + (0, _utils.capitalize)(_fldName)];\n if (func) {\n subValues = func(values, _fldName);\n } else {\n subValues = values;\n }\n\n var sub = new Sub();\n newValues[_fldName] = sub.parse(subValues, forceValidation);\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n }\n values = _extends({}, this.state.values || {}, newValues);\n }\n\n // Call for any overloaded parsing. This is useful for things like\n // conversion to form select objects. This is preferable to\n // overlading `parse` as we want to do a single validation at the\n // end of value parsing.\n if (this.parseValues) {\n values = this.parseValues(values);\n }\n\n this.state = _extends({}, this.state, {\n values: values,\n touched: {},\n initial: initial\n\n // Render my flat version of values. Do this after we've recursed\n // so as to have all my values already rendered.\n });this.render();\n\n this.validate(forceValidation);\n return this.state;\n }\n }, {\n key: 'render',\n value: function render() {\n var values = this.state.values;\n\n var flat = void 0;\n if (Array.isArray(this.nested)) {\n flat = values.map(function (sub) {\n return sub.flat;\n });\n } else {\n if (this.fields) {\n flat = {};\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = this.fields[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var fldName = _step3.value;\n\n flat[fldName] = values[fldName];\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n } else {\n flat = _extends({}, values);\n }\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = Object.keys(this.nested)[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var _fldName2 = _step4.value;\n\n var func = this['render' + (0, _utils.capitalize)(_fldName2)];\n var subFlat = this.state.values[_fldName2].flat;\n if (func) {\n flat = func(flat, subFlat);\n } else {\n if (Array.isArray(subFlat)) {\n flat[_fldName2] = subFlat;\n } else {\n flat = _extends({}, flat, subFlat);\n }\n }\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n }\n this.state.flat = this.renderValues(flat);\n return flat;\n }\n }, {\n key: 'renderValues',\n value: function renderValues(values) {\n return values;\n }\n }, {\n key: 'validate',\n value: function validate(force) {\n this.forceValidation = force; // isTouched always returns true\n var errorSet = new _ErrorSet2.default();\n\n // If we're forcing validation we need to go over all sub-forms too.\n // Forced validation usually occurs from a parent form, and there's\n // no guarantee any of the subforms will have been validated.\n var values = this.getValues();\n if (force) {\n if (Array.isArray(values)) {\n var SubForm = this.nested[0];\n values = values.map(function (subValue) {\n var sub = new SubForm(subValue);\n sub.validate(force);\n return sub.state;\n });\n } else {\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = Object.entries(this.nested)[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var _ref3 = _step5.value;\n\n var _ref4 = _slicedToArray(_ref3, 2);\n\n var fieldName = _ref4[0];\n var _SubForm = _ref4[1];\n\n if (values[fieldName] !== undefined) {\n var sub = new _SubForm(values[fieldName]);\n sub.validate(force);\n values[fieldName] = sub.state;\n }\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n }\n this.state = _extends({}, this.state, {\n values: values\n });\n }\n\n // Perform my local validation.\n this.validateFields(errorSet);\n this.validateForm(errorSet);\n\n // If the form value is an array add up counts from the sub-\n // forms in the array. Otherwise check if any sub-form fields\n // have counts to add.\n if (Array.isArray(values)) {\n var _iteratorNormalCompletion6 = true;\n var _didIteratorError6 = false;\n var _iteratorError6 = undefined;\n\n try {\n for (var _iterator6 = values[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {\n var _sub = _step6.value;\n var _sub$errors = _sub.errors,\n errors = _sub$errors === undefined ? {} : _sub$errors;\n var _iteratorNormalCompletion7 = true;\n var _didIteratorError7 = false;\n var _iteratorError7 = undefined;\n\n try {\n for (var _iterator7 = Object.entries(errors.counts || {})[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {\n var _ref5 = _step7.value;\n\n var _ref6 = _slicedToArray(_ref5, 2);\n\n var type = _ref6[0];\n var count = _ref6[1];\n\n errorSet.updateCounts(type, count);\n }\n } catch (err) {\n _didIteratorError7 = true;\n _iteratorError7 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion7 && _iterator7.return) {\n _iterator7.return();\n }\n } finally {\n if (_didIteratorError7) {\n throw _iteratorError7;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError6 = true;\n _iteratorError6 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion6 && _iterator6.return) {\n _iterator6.return();\n }\n } finally {\n if (_didIteratorError6) {\n throw _iteratorError6;\n }\n }\n }\n } else {\n var _iteratorNormalCompletion8 = true;\n var _didIteratorError8 = false;\n var _iteratorError8 = undefined;\n\n try {\n for (var _iterator8 = Object.keys(this.nested)[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {\n var _fieldName = _step8.value;\n\n var _sub2 = values[_fieldName];\n\n var _ref7 = _sub2 || {},\n _ref7$errors = _ref7.errors,\n _errors = _ref7$errors === undefined ? {} : _ref7$errors;\n\n var _iteratorNormalCompletion9 = true;\n var _didIteratorError9 = false;\n var _iteratorError9 = undefined;\n\n try {\n for (var _iterator9 = Object.entries(_errors.counts || {})[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {\n var _ref8 = _step9.value;\n\n var _ref9 = _slicedToArray(_ref8, 2);\n\n var _type = _ref9[0];\n var _count = _ref9[1];\n\n errorSet.updateCounts(_type, _count);\n }\n } catch (err) {\n _didIteratorError9 = true;\n _iteratorError9 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion9 && _iterator9.return) {\n _iterator9.return();\n }\n } finally {\n if (_didIteratorError9) {\n throw _iteratorError9;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError8 = true;\n _iteratorError8 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion8 && _iterator8.return) {\n _iterator8.return();\n }\n } finally {\n if (_didIteratorError8) {\n throw _iteratorError8;\n }\n }\n }\n }\n\n this.state = _extends({}, this.state, {\n errors: errorSet.errors\n });\n\n return this.state;\n }\n }, {\n key: 'validateFields',\n value: function validateFields(errors) {\n var _iteratorNormalCompletion10 = true;\n var _didIteratorError10 = false;\n var _iteratorError10 = undefined;\n\n try {\n for (var _iterator10 = this.iterFieldValidators()[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {\n var _ref10 = _step10.value;\n\n var _ref11 = _slicedToArray(_ref10, 2);\n\n var fieldName = _ref11[0];\n var fieldValidator = _ref11[1];\n\n if (!this.isTouched(fieldName)) {\n continue;\n }\n fieldValidator(errors, fieldName, this);\n }\n } catch (err) {\n _didIteratorError10 = true;\n _iteratorError10 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion10 && _iterator10.return) {\n _iterator10.return();\n }\n } finally {\n if (_didIteratorError10) {\n throw _iteratorError10;\n }\n }\n }\n }\n }, {\n key: 'validateForm',\n value: function validateForm(errors) {}\n }, {\n key: 'iterFieldValidators',\n value: /*#__PURE__*/regeneratorRuntime.mark(function iterFieldValidators() {\n var _iteratorNormalCompletion11, _didIteratorError11, _iteratorError11, _iterator11, _step11, _ref12, _ref13, fn, fvs, _iteratorNormalCompletion12, _didIteratorError12, _iteratorError12, _iterator12, _step12, fv;\n\n return regeneratorRuntime.wrap(function iterFieldValidators$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n _iteratorNormalCompletion11 = true;\n _didIteratorError11 = false;\n _iteratorError11 = undefined;\n _context.prev = 3;\n _iterator11 = Object.entries(this.fieldValidators)[Symbol.iterator]();\n\n case 5:\n if (_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done) {\n _context.next = 39;\n break;\n }\n\n _ref12 = _step11.value;\n _ref13 = _slicedToArray(_ref12, 2);\n fn = _ref13[0];\n fvs = _ref13[1];\n _iteratorNormalCompletion12 = true;\n _didIteratorError12 = false;\n _iteratorError12 = undefined;\n _context.prev = 13;\n _iterator12 = fvs[Symbol.iterator]();\n\n case 15:\n if (_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done) {\n _context.next = 22;\n break;\n }\n\n fv = _step12.value;\n _context.next = 19;\n return [fn, fv];\n\n case 19:\n _iteratorNormalCompletion12 = true;\n _context.next = 15;\n break;\n\n case 22:\n _context.next = 28;\n break;\n\n case 24:\n _context.prev = 24;\n _context.t0 = _context['catch'](13);\n _didIteratorError12 = true;\n _iteratorError12 = _context.t0;\n\n case 28:\n _context.prev = 28;\n _context.prev = 29;\n\n if (!_iteratorNormalCompletion12 && _iterator12.return) {\n _iterator12.return();\n }\n\n case 31:\n _context.prev = 31;\n\n if (!_didIteratorError12) {\n _context.next = 34;\n break;\n }\n\n throw _iteratorError12;\n\n case 34:\n return _context.finish(31);\n\n case 35:\n return _context.finish(28);\n\n case 36:\n _iteratorNormalCompletion11 = true;\n _context.next = 5;\n break;\n\n case 39:\n _context.next = 45;\n break;\n\n case 41:\n _context.prev = 41;\n _context.t1 = _context['catch'](3);\n _didIteratorError11 = true;\n _iteratorError11 = _context.t1;\n\n case 45:\n _context.prev = 45;\n _context.prev = 46;\n\n if (!_iteratorNormalCompletion11 && _iterator11.return) {\n _iterator11.return();\n }\n\n case 48:\n _context.prev = 48;\n\n if (!_didIteratorError11) {\n _context.next = 51;\n break;\n }\n\n throw _iteratorError11;\n\n case 51:\n return _context.finish(48);\n\n case 52:\n return _context.finish(45);\n\n case 53:\n case 'end':\n return _context.stop();\n }\n }\n }, iterFieldValidators, this, [[3, 41, 45, 53], [13, 24, 28, 36], [29,, 31, 35], [46,, 48, 52]]);\n })\n\n /**\n * TODO: This method has gotten a little crazy.\n */\n\n }, {\n key: 'updateIn',\n value: function updateIn(payload, path) {\n if (path === undefined) {\n path = [];\n } else if (!Array.isArray(path)) {\n path = path.split('.');\n }\n if (path.length > 0) {\n var subKey = void 0;\n var subForm = void 0;\n if (Array.isArray(this.nested)) {\n subKey = parseInt(path[0]);\n var SubForm = this.nested[0];\n subForm = new SubForm(this.state.values[subKey]);\n } else {\n subKey = path[0];\n var _SubForm2 = this.nested[subKey];\n subForm = new _SubForm2(this.state.values[subKey]);\n }\n subForm.updateIn(payload, path.slice(1));\n this.updateValue(subKey, subForm.state);\n } else {\n if (Array.isArray(this.nested) && Array.isArray(payload)) {\n var _iteratorNormalCompletion13 = true;\n var _didIteratorError13 = false;\n var _iteratorError13 = undefined;\n\n try {\n for (var _iterator13 = payload[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {\n var item = _step13.value;\n\n this.updateValue(null, item);\n }\n } catch (err) {\n _didIteratorError13 = true;\n _iteratorError13 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion13 && _iterator13.return) {\n _iterator13.return();\n }\n } finally {\n if (_didIteratorError13) {\n throw _iteratorError13;\n }\n }\n }\n } else {\n var _iteratorNormalCompletion14 = true;\n var _didIteratorError14 = false;\n var _iteratorError14 = undefined;\n\n try {\n for (var _iterator14 = Object.entries(payload)[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {\n var _ref14 = _step14.value;\n\n var _ref15 = _slicedToArray(_ref14, 2);\n\n var key = _ref15[0];\n var value = _ref15[1];\n\n if (key.includes('.')) {\n var splitKey = key.split('.');\n this.updateIn(_defineProperty({}, splitKey[splitKey.length - 1], value), splitKey.slice(0, splitKey.length - 1));\n } else {\n this.updateValue(key, value);\n }\n }\n } catch (err) {\n _didIteratorError14 = true;\n _iteratorError14 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion14 && _iterator14.return) {\n _iterator14.return();\n }\n } finally {\n if (_didIteratorError14) {\n throw _iteratorError14;\n }\n }\n }\n }\n }\n this.render();\n }\n }, {\n key: 'updateValue',\n value: function updateValue(name, value) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n\n var values = this.getValues();\n var touched = this.state.touched;\n var errors = void 0;\n if (Array.isArray(values)) {\n var SubForm = this.nested[0];\n\n // TODO: Manage touched when removing an array item.\n var names = void 0;\n if (!Array.isArray(name)) {\n names = [name];\n } else {\n names = name;\n }\n var _iteratorNormalCompletion15 = true;\n var _didIteratorError15 = false;\n var _iteratorError15 = undefined;\n\n try {\n for (var _iterator15 = names[Symbol.iterator](), _step15; !(_iteratorNormalCompletion15 = (_step15 = _iterator15.next()).done); _iteratorNormalCompletion15 = true) {\n var _name = _step15.value;\n\n\n // Null name indicates appending an entry to the array.\n if (_name === null) {\n var subForm = new SubForm();\n subForm.parse(value);\n values = [].concat(_toConsumableArray(values), [subForm.state]);\n }\n\n // A value for name indicates either deletion or bulk\n // update. Deletion is carried out when value is null.\n // Anything other than null is merged.\n else {\n _name = parseInt(_name);\n if (_name >= 0 && _name < values.length) {\n values = [].concat(_toConsumableArray(values.slice(0, _name)), [options.merge ? mergeValues(this.nested[0], values[_name], value) : value], _toConsumableArray(values.slice(_name + 1)));\n }\n }\n }\n } catch (err) {\n _didIteratorError15 = true;\n _iteratorError15 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion15 && _iterator15.return) {\n _iterator15.return();\n }\n } finally {\n if (_didIteratorError15) {\n throw _iteratorError15;\n }\n }\n }\n\n values = values.filter(function (x) {\n return x !== null;\n });\n } else {\n values = _extends({}, values, _defineProperty({}, name, value));\n touched = this.updateTouched(name, value, this.state.touched);\n }\n this.state = _extends({}, this.state, {\n values: values,\n touched: touched\n });\n this.state.errors = this.validate();\n if (errors) {\n this.state.errors = _ErrorSet2.default.merge(this.state.errors, errors);\n }\n }\n }, {\n key: 'updateTouched',\n value: function updateTouched(name, value, touched) {\n var initial = this.getInitial();\n touched = this.getTouched(touched);\n return _extends({}, touched, _defineProperty({}, name, !!(touched[name] || false || !!value || initial[name] != value)));\n }\n }, {\n key: 'isTouched',\n value: function isTouched(name, touched) {\n var _lookupForm = this.lookupForm(name),\n _lookupForm2 = _slicedToArray(_lookupForm, 2),\n state = _lookupForm2[0],\n last = _lookupForm2[1];\n\n if (this.forceValidation) {\n // One is added to the touched value so that after a forced\n // validation the form doesn't forget about showing the error\n // after future changes.\n state.touched[last] = true;\n }\n return state.touched[last] || false;\n }\n }, {\n key: 'getTouched',\n value: function getTouched(touched) {\n return this._getState(touched, 'touched', {});\n }\n }, {\n key: 'getInitial',\n value: function getInitial(initial) {\n return this._getState(initial, 'initial', {});\n }\n }, {\n key: 'getValues',\n value: function getValues(values) {\n return this._getState(values, 'values', this.defaultValues);\n }\n }, {\n key: 'getValue',\n value: function getValue(name) {\n var _lookupForm3 = this.lookupForm(name),\n _lookupForm4 = _slicedToArray(_lookupForm3, 2),\n state = _lookupForm4[0],\n last = _lookupForm4[1];\n\n return name ? state.values[last] : state.values;\n }\n }, {\n key: 'lookupForm',\n value: function lookupForm(name) {\n var state = this.state;\n if (name) {\n var parts = name.split('.');\n var _iteratorNormalCompletion16 = true;\n var _didIteratorError16 = false;\n var _iteratorError16 = undefined;\n\n try {\n for (var _iterator16 = parts.slice(0, parts.length - 1)[Symbol.iterator](), _step16; !(_iteratorNormalCompletion16 = (_step16 = _iterator16.next()).done); _iteratorNormalCompletion16 = true) {\n var part = _step16.value;\n\n state = state.values[part];\n }\n } catch (err) {\n _didIteratorError16 = true;\n _iteratorError16 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion16 && _iterator16.return) {\n _iterator16.return();\n }\n } finally {\n if (_didIteratorError16) {\n throw _iteratorError16;\n }\n }\n }\n\n name = parts[parts.length - 1];\n }\n return [state, name];\n }\n }, {\n key: '_getState',\n value: function _getState(value, name, fallback) {\n if (value === undefined) {\n value = this.state[name] || fallback;\n }\n return value;\n }\n }]);\n\n return Form;\n}(), _class.ERROR = 'error', _class.WARNING = 'warning', _class.normalizeErrors = function () {\n var errors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return _extends({\n fields: {},\n form: [],\n counts: {}\n }, errors);\n}, _class.normalize = function (value) {\n return _extends({\n touched: {},\n errors: Form.normalizeErrors(),\n values: {}\n }, value);\n}, _temp);\nexports.default = Form;\n\n//# sourceURL=webpack://react-nested-validation/./src/Form.js?");
/***/ }),
/***/ "./src/asForm.js":
/*!***********************!*\
!*** ./src/asForm.js ***!
\***********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _react = __webpack_require__(/*! react */ \"react\");\n\nvar _react2 = _interopRequireDefault(_react);\n\nvar _Form2 = __webpack_require__(/*! ./Form */ \"./src/Form.js\");\n\nvar _Form3 = _interopRequireDefault(_Form2);\n\nvar _utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n/**\n * HOC to turn a React class into a form.\n */\nexports.default = function () {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return function (Inner) {\n var _class, _temp;\n\n return _temp = _class = function (_React$Component) {\n _inherits(_class, _React$Component);\n\n function _class(props) {\n _classCallCheck(this, _class);\n\n var _this = _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).call(this, props));\n\n _this.getFormClass = function () {\n return _this.props.Form || options.form;\n };\n\n _this.makeForm = function (forceValidation) {\n var Form = _this.getFormClass();\n var form = new Form(_this.getFormState());\n if (forceValidation) {\n form.validate(true);\n }\n return form;\n };\n\n _this.getFormState = function () {\n var _this$props$form = _this.props.form,\n form = _this$props$form === undefined ? {} : _this$props$form;\n\n if (!(form || {}).values) {\n var _Form = _this.getFormClass();\n form = new _Form().parse(_this.props.initial);\n }\n return _Form3.default.normalize(_extends({}, form));\n };\n\n _this.handleChange2 = function (payload, path) {\n var _this$props = _this.props,\n onChange = _this$props.onChange,\n formPrefix = _this$props.formPrefix;\n\n if (!(0, _utils.isNil)(formPrefix)) {\n console.debug('Deferring form update with prefix and path: ', formPrefix, path);\n if (!(0, _utils.isNil)(path)) {\n path = formPrefix + '.' + path;\n } else {\n path = formPrefix;\n }\n if (onChange) {\n onChange(payload, path);\n }\n } else {\n console.debug('Form changed with path and payload: ', path, payload);\n var form = _this.makeForm();\n form.updateIn(payload, path);\n console.debug(' New state: ', form.state);\n if (onChange) {\n onChange({\n state: form.state,\n values: form.flat,\n payload: payload,\n path: path\n });\n }\n }\n };\n\n _this.handleChange = function (name, value, options) {\n var form = _this.makeForm();\n form.updateValue(name, value, options);\n var _this$props2 = _this.props,\n onChange = _this$props2.onChange,\n formPrefix = _this$props2.formPrefix;\n\n if (onChange) {\n if (!(0, _utils.isNil)(formPrefix)) {\n onChange(formPrefix, form.state);\n } else {\n onChange(form.state, name, value);\n }\n }\n };\n\n _this.validate = function (force) {\n var errors = _this.makeForm().validate();\n _this.setState({ errors: errors });\n };\n\n if (!props.form) {\n var form = _this.makeForm();\n if (props.onChange) {\n props.onChange({ state: form.state });\n }\n }\n return _this;\n }\n\n // TODO: Deprecate.\n /* getFormValues = () => {\n * const {form} = this.props\n * let values = (form || {}).values\n * if (!values) {\n * let Form = options.form\n * values = new Form().parse(this.props.initial).values\n * }\n * return values\n * } */\n\n _createClass(_class, [{\n key: 'shouldComponentUpdate',\n value: function shouldComponentUpdate(nextProps) {\n return (nextProps.form || {}).values != (this.props.form || {}).values || (nextProps.form || {}).errors != (this.props.form || {}).errors || this.props.shouldUpdate && this.props.shouldUpdate(nextProps, this.props);\n }\n }, {\n key: 'render',\n value: function render() {\n\n // Need to be sure we have at least an object value\n // for form.\n var _props = this.props,\n form = _props.form,\n Form = _props.Form,\n otherProps = _objectWithoutProperties(_props, ['form', 'Form']);\n\n if ((0, _utils.isNil)(form)) {\n form = this.makeForm(this.props.forceValidation).state;\n }\n\n return _react2.default.createElement(Inner, _extends({}, otherProps, {\n form: form,\n onChange: this.handleChange2\n }));\n }\n }]);\n\n return _class;\n }(_react2.default.Component), _class.Form = options.form, _temp;\n };\n};\n\n//# sourceURL=webpack://react-nested-validation/./src/asForm.js?");
/***/ }),
/***/ "./src/asFormWizard.js":
/*!*****************************!*\
!*** ./src/asFormWizard.js ***!
\*****************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _react = __webpack_require__(/*! react */ \"react\");\n\nvar _react2 = _interopRequireDefault(_react);\n\nvar _utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\n\nvar _asForm = __webpack_require__(/*! ./asForm */ \"./src/asForm.js\");\n\nvar _asForm2 = _interopRequireDefault(_asForm);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nfunction _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }\n\n/**\n * HOC to turn a React class into a form.\n */\nexports.default = function (options) {\n return function (Inner) {\n var _dec, _class, _class2, _temp2;\n\n var initialPage = options.initialPage,\n otherOpts = _objectWithoutProperties(options, ['initialPage']);\n\n var Outer = (_dec = (0, _asForm2.default)(otherOpts), _dec(_class = (_temp2 = _class2 = function (_React$Component) {\n _inherits(Outer, _React$Component);\n\n function Outer() {\n var _ref;\n\n var _temp, _this, _ret;\n\n _classCallCheck(this, Outer);\n\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Outer.__proto__ || Object.getPrototypeOf(Outer)).call.apply(_ref, [this].concat(args))), _this), _this.state = {\n page: (0, _utils.isFunc)(initialPage) ? initialPage(_this.props) : initialPage,\n history: [],\n visited: {}\n }, _this.nextPage = function (form, next, invalid) {\n var _this$state = _this.state,\n page = _this$state.page,\n visited = _this$state.visited;\n\n if (!!form) {\n form.validate(true);\n }\n var firstTime = !visited[page];\n if (!!form && (form.state.errors.counts.error > 0 || form.state.errors.counts.warning > 0 && firstTime)) {\n if (invalid) {\n invalid(page, form);\n }\n _this.setState({ visited: _extends({}, visited, _defineProperty({}, page, true)) });\n } else if ((0, _utils.isFunc)(next)) {\n next();\n } else {\n _this.setState({\n page: next,\n visited: _extends({}, visited, _defineProperty({}, page, true)),\n history: [].concat(_toConsumableArray(_this.state.history), [page])\n });\n }\n }, _this.previousPage = function () {\n var history = _this.state.history;\n\n if (history.length > 0) {\n _this.setState({\n page: history[history.length - 1],\n history: history.slice(0, history.length - 1)\n });\n }\n }, _this.renderPage = function (component) {\n var page = _this.state.page;\n\n var funcName = 'render' + (0, _utils.capitalize)(page);\n return component[funcName]();\n }, _temp), _possibleConstructorReturn(_this, _ret);\n }\n\n _createClass(Outer, [{\n key: 'render',\n value: function render() {\n return _react2.default.createElement(Inner, _extends({}, this.props, {\n nextPage: this.nextPage,\n previousPage: this.previousPage,\n finishWizard: this.finishWizard,\n renderPage: this.renderPage\n }));\n }\n }]);\n\n return Outer;\n }(_react2.default.Component), _class2.Form = options.form, _temp2)) || _class);\n\n return Outer;\n };\n};\n\n//# sourceURL=webpack://react-nested-validation/./src/asFormWizard.js?");
/***/ }),
/***/ "./src/index.js":
/*!**********************!*\
!*** ./src/index.js ***!
\**********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.Form = exports.asFormWizard = exports.asForm = undefined;\n\nvar _validators = __webpack_require__(/*! ./validators */ \"./src/validators.js\");\n\nObject.keys(_validators).forEach(function (key) {\n if (key === \"default\" || key === \"__esModule\") return;\n Object.defineProperty(exports, key, {\n enumerable: true,\n get: function get() {\n return _validators[key];\n }\n });\n});\n\nvar _asForm2 = __webpack_require__(/*! ./asForm */ \"./src/asForm.js\");\n\nvar _asForm3 = _interopRequireDefault(_asForm2);\n\nvar _asFormWizard2 = __webpack_require__(/*! ./asFormWizard */ \"./src/asFormWizard.js\");\n\nvar _asFormWizard3 = _interopRequireDefault(_asFormWizard2);\n\nvar _Form2 = __webpack_require__(/*! ./Form */ \"./src/Form.js\");\n\nvar _Form3 = _interopRequireDefault(_Form2);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.asForm = _asForm3.default; /* eslint-disable */\n\nexports.asFormWizard = _asFormWizard3.default;\nexports.Form = _Form3.default;\n\n//# sourceURL=webpack://react-nested-validation/./src/index.js?");
/***/ }),
/***/ "./src/utils.js":
/*!**********************!*\
!*** ./src/utils.js ***!
\**********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n/**\n * Check for a \"nil\" value; undefined, null, or an empty string.\n */\nvar isNil = exports.isNil = function isNil(value) {\n return value === undefined || value === null || value === '';\n};\n\nvar isFunc = exports.isFunc = function isFunc(value) {\n return typeof value === 'function';\n};\n\nvar capitalize = exports.capitalize = function capitalize(value) {\n return '' + value[0].toUpperCase() + value.slice(1);\n};\n\n//# sourceURL=webpack://react-nested-validation/./src/utils.js?");
/***/ }),
/***/ "./src/validators.js":
/*!***************************!*\
!*** ./src/validators.js ***!
\***************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.emptyWarning = exports.required = undefined;\n\nvar _Form = __webpack_require__(/*! ./Form */ \"./src/Form.js\");\n\nvar _Form2 = _interopRequireDefault(_Form);\n\nvar _utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * Helper to create a message for a validation error.\n *\n * @param {(string|function)} message How to get the message.\n * @param {string} fieldName Field name generating the error.\n * @param {Form} form The form the error came from.\n * @param {string} defaultMessage The default message to use.\n */\nvar makeMessage = function makeMessage(message, fieldName, form, defaultMessage) {\n if (message instanceof Function) {\n return message(fieldName, form);\n } else {\n return message || defaultMessage;\n }\n};\n\nvar missing = function missing(errors, fieldName, form, message, type, defaultMessage) {\n var value = form.getValue(fieldName);\n if ((0, _utils.isNil)(value)) {\n errors.addFieldError(fieldName, makeMessage(message, fieldName, form, defaultMessage), type);\n }\n};\n\n/**\n * Validator creator for a required field. Returns a function that may\n * be called to validate a field has a non-nil value; should the check\n * fail an error will be assigned.\n *\n * The provided message may be a string, a function, or nil. A function\n * will be called with the field name and the form. A nil value for the\n * message will use the default message.\n *\n * @param {string} message The error message to display.\n * @returns {func}\n */\nvar required = exports.required = function required(message) {\n return function (errors, fieldName, form) {\n return missing(errors, fieldName, form, message, _Form2.default.ERROR, required.DEFAULT_MESSAGE);\n };\n};\n\nrequired.DEFAULT_MESSAGE = 'This field is required.';\n\n/**\n * Validator creator for an empty field check. Returns a function that may\n * be called to validate a field has a non-nil value; should the check\n * fail a warning will be assigned.\n *\n * The provided message may be a string, or a function. A function\n * will be called with the field name and the form.\n *\n * @param {string} message The error message to display.\n * @returns {func}\n */\nvar emptyWarning = exports.emptyWarning = function emptyWarning(message) {\n return function (errors, fieldName, form) {\n return missing(errors, fieldName, form, message, _Form2.default.WARNING);\n };\n};\n\n//# sourceURL=webpack://react-nested-validation/./src/validators.js?");
/***/ }),
/***/ 0:
/*!*************************!*\
!*** multi ./src/index ***!
\*************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
eval("module.exports = __webpack_require__(/*! ./src/index */\"./src/index.js\");\n\n\n//# sourceURL=webpack://react-nested-validation/multi_./src/index?");
/***/ }),
/***/ "react":
/*!************************!*\
!*** external "react" ***!
\************************/
/*! no static exports found */
/***/ (function(module, exports) {
eval("module.exports = __WEBPACK_EXTERNAL_MODULE_react__;\n\n//# sourceURL=webpack://react-nested-validation/external_%22react%22?");
/***/ })
/******/ });
});

2

package.json
{
"name": "react-nested-validation",
"version": "0.2.2",
"version": "0.2.3",
"description": "A toolkit for performing nested validation of React forms.",

@@ -5,0 +5,0 @@ "esnext": "src/index.js",

@@ -93,4 +93,5 @@ import ErrorSet from './ErrorSet'

})
const stateValues = Array.isArray(this.state.values) ? this.state.values : []
values = [
...(this.state.values || []),
...(stateValues || []),
...values

@@ -97,0 +98,0 @@ ]

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc