react-verificator
Version:
React validation JavaScript library
2 lines (1 loc) • 2.69 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("verificator/es")):"function"==typeof define&&define.amd?define(["exports","react","verificator/es"],e):e(t.ReactVerificator={},t.React,t.Verificator)}(this,function(t,o,e){"use strict";var c="default"in o?o.default:o;"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var r,p=(function(t,e){var s,u,f,l,d,y,b,v;t.exports=(s={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},u={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},f=Object.defineProperty,l=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols,y=Object.getOwnPropertyDescriptor,v=(b=Object.getPrototypeOf)&&b(Object),function t(e,o,r){if("string"!=typeof o){if(v){var n=b(o);n&&n!==v&&t(e,n,r)}var i=l(o);d&&(i=i.concat(d(o)));for(var a=0;a<i.length;++a){var c=i[a];if(!(s[c]||u[c]||r&&r[c])){var p=y(o,c);try{f(e,c,p)}catch(t){}}}return e}return e})}(r={exports:{}},r.exports),r.exports),n=function(t){return{validator:t.validator}};t.Validator=e.Validator,t.validator=function(t){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:n,a=new e.Validator({},t.rules,t.customLocale);return"function"!=typeof i&&(i=n),function(n){var t="Validator("+(n.displayName||n.name||"Component")+")",e=function(o){function r(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r);var e=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,o.call(this,t));return e.state={validator:a},e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(r,o),r.prototype.componentWillMount=function(){var t=this;this.unsubscribe=this.state.validator.subscribe(function(){t.setState({validator:t.state.validator})})},r.prototype.componentWillUnmount=function(){this.unsubscribe()},r.prototype.calculateMapToProps=function(){return i({validator:a,ownProps:this.props})},r.prototype.render=function(){var t=this.props,e=this.calculateMapToProps(),o=Object.assign({},t,e);return c.createElement(n,Object.assign({},o))},r}(o.Component);return e.displayName=t,e.WrappedComponent=n,p(e,n)}},Object.defineProperty(t,"__esModule",{value:!0})});