react-form-validator-component
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -0,0 +0,0 @@ module.exports = { |
@@ -1,1 +0,1 @@ | ||
!function(e,r){for(var t in r)e[t]=r[t]}(exports,function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=6)}([function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,o=/^([a-zA-Z0-9_\-.]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,5}){1,25}(,[ ]{0,1}([a-zA-Z0-9_\-.]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,5}){1,25})*$/,a=/^[a-zA-Z]+(([',. -][a-zA-Z ])?[a-zA-Z]*)*$/,i=/^[+]?(\d{1,3})\s?(\d{10})$/,u=/^(([A-Za-z0-9]{2,4})\s?([A-Za-z0-9]{1,5})?)?$/,l={validator:function(e){return!!e.match(a)},error:"Please provide a full name"},s={validator:function(e){return!!e.match(n)},error:"Please provide a valid email address"},c={validator:function(e){return!!e.match(o)},error:"Please provide a valid email address, or several emails comma delimited"},f={validator:function(e){return!!e.match(i)},error:"Please provide a valid UK phone number"},d={validator:function(e){return!!e.match(u)},error:"Please provide a valid UK postcode"};r.isRequired={validator:function(e){return!!e},error:"Please provide a value"},r.isEmail=s,r.isEmailArray=c,r.isFullName=l,r.isPhoneNumber=f,r.isPostcode=d},function(e,r,t){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,r,t){"use strict";var n=t(1);function o(){}e.exports=function(){function e(e,r,t,o,a,i){if(i!==n){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}function r(){return e}e.isRequired=e;var t={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:r,element:e,instanceOf:r,node:e,objectOf:r,oneOf:r,oneOfType:r,shape:r,exact:r};return t.checkPropTypes=o,t.PropTypes=t,t}},function(e,r,t){e.exports=t(2)()},function(e,r){e.exports=require("react")},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=function(){return function(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,r){var t=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,a=e}finally{try{!n&&u.return&&u.return()}finally{if(o)throw a}}return t}(e,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=function(){function e(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(r,t,n){return t&&e(r.prototype,t),n&&e(r,n),r}}(),a=l(t(4)),i=l(t(3)),u=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0));function l(e){return e&&e.__esModule?e:{default:e}}function s(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);r<e.length;r++)t[r]=e[r];return t}return Array.from(e)}function c(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var f=function(e){function r(e){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r);var t=function(e,r){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!r||"object"!=typeof r&&"function"!=typeof r?e:r}(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t.onPassValidation=function(e,r){t.props.parent.setState(c({},e,r))},t.toArray=function(e){return Object.entries(e).reduce(function(e,r){var t=n(r,2),o=t[0],a=t[1];return e.concat({key:o,value:a})},[])},t.addToStateProperty=function(e,r){t.setState(c({},t.state[e],Object.assign(t.state[e],r)))},t.removeError=function(e,r){var n=t.state.errors[e],o=n.indexOf(r);o>-1&&n.splice(o,1),t.addToStateProperty("errors",c({},e,n))},t.updateErrors=function(e,r,n){e?t.removeError(r,n):t.addToStateProperty("errors",c({},r,[].concat(s(new Set([].concat(s(t.state.errors[r]||[]),[n]))))))},t.validateField=function(e,r){var n=t.state.fields[e].rules.reduce(function(n,o){var a=u[o]||o,i=a.validator(r);return t.updateErrors(i,e,a.error),n&&i},!0);return t.setState({validation:Object.assign(t.state.validation,c({},e,n))}),n},t.onChange=function(e){var r=e.target.name,n=e.target.value,o=t.props.onPassValidation||t.onPassValidation;t.validateField(r,n)?o(r,n):t.props.parent.setState(c({},r,void 0)),t.setState({isFormValid:Object.values(t.state.validation).every(function(e){return e})})},t.state={fields:e.fields,errors:Object.keys(e.fields).reduce(function(e,r){return e[r]=[],e},{}),validation:{},isFormValid:!1},t}return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function, not "+typeof r);e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),r&&(Object.setPrototypeOf?Object.setPrototypeOf(e,r):e.__proto__=r)}(r,a.default.Component),o(r,[{key:"render",value:function(){var e=this.state,r=e.fields,t=e.errors,n=e.isFormValid,o=e.validation;return this.props.children({isFormValid:n,isFieldValid:o,fields:this.toArray(r),onChange:this.onChange,errors:t})}}]),r}();r.default=f,f.propTypes={parent:i.default.object,children:i.default.func,onPassValidation:i.default.func,fields:i.default.object}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Validator=void 0;var n=function(e){return e&&e.__esModule?e:{default:e}}(t(5));r.Validator=n.default}])); | ||
!function(e,r){for(var t in r)e[t]=r[t]}(exports,function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=6)}([function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,o=/^([a-zA-Z0-9_\-.]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,5}){1,25}(,[ ]{0,1}([a-zA-Z0-9_\-.]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,5}){1,25})*$/,a=/^[a-zA-Z]+(([',. -][a-zA-Z ])?[a-zA-Z]*)*$/,i=/^[+]?(\d{1,3})\s?(\d{10})$/,u=/^(([A-Za-z0-9]{2,4})\s?([A-Za-z0-9]{1,5})?)?$/,l={validator:function(e){return!!e.match(a)},error:"Please provide a full name"},s={validator:function(e){return!!e.match(n)},error:"Please provide a valid email address"},c={validator:function(e){return!!e.match(o)},error:"Please provide a valid email address, or several emails comma delimited"},f={validator:function(e){return!!e.match(i)},error:"Please provide a valid UK phone number"},d={validator:function(e){return!!e.match(u)},error:"Please provide a valid UK postcode"};r.isRequired={validator:function(e){return!!e},error:"Please provide a value"},r.isEmail=s,r.isEmailArray=c,r.isFullName=l,r.isPhoneNumber=f,r.isPostcode=d},function(e,r,t){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,r,t){"use strict";var n=t(1);function o(){}e.exports=function(){function e(e,r,t,o,a,i){if(i!==n){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}function r(){return e}e.isRequired=e;var t={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:r,element:e,instanceOf:r,node:e,objectOf:r,oneOf:r,oneOfType:r,shape:r,exact:r};return t.checkPropTypes=o,t.PropTypes=t,t}},function(e,r,t){e.exports=t(2)()},function(e,r){e.exports=require("react")},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=function(){return function(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,r){var t=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,a=e}finally{try{!n&&u.return&&u.return()}finally{if(o)throw a}}return t}(e,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),o=function(){function e(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(r,t,n){return t&&e(r.prototype,t),n&&e(r,n),r}}(),a=l(t(4)),i=l(t(3)),u=function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}(t(0));function l(e){return e&&e.__esModule?e:{default:e}}function s(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);r<e.length;r++)t[r]=e[r];return t}return Array.from(e)}function c(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var f=function(e){function r(e){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r);var t=function(e,r){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!r||"object"!=typeof r&&"function"!=typeof r?e:r}(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t.onPassValidation=function(e,r){t.props.parent.setState(c({},e,r))},t.toArray=function(e){return Object.entries(e).reduce(function(e,r){var t=n(r,2),o=t[0],a=t[1];return e.concat({key:o,value:a})},[])},t.addToStateProperty=function(e,r){t.setState(c({},t.state[e],Object.assign(t.state[e],r)))},t.removeError=function(e,r){var n=t.state.errors[e],o=n.indexOf(r);o>-1&&n.splice(o,1),t.addToStateProperty("errors",c({},e,n))},t.updateErrors=function(e,r,n){e?t.removeError(r,n):t.addToStateProperty("errors",c({},r,[].concat(s(new Set([].concat(s(t.state.errors[r]||[]),[n]))))))},t.validateField=function(e,r){var n=t.state.fields[e].rules.reduce(function(n,o){var a=u[o]||o,i=a.validator(r);return t.updateErrors(i,e,a.error),n&&i},!0);return t.setState({validation:Object.assign(t.state.validation,c({},e,n))}),n},t.onChange=function(e){var r=e.target.name,n=e.target.value,o=t.props.fields[r].onPassValidation||t.props.onPassValidation||t.onPassValidation;t.validateField(r,n)?o(r,n):t.props.parent.setState(c({},r,void 0)),t.setState({isFormValid:Object.values(t.state.validation).every(function(e){return e})})},t.state={fields:e.fields,errors:Object.keys(e.fields).reduce(function(e,r){return e[r]=[],e},{}),validation:{},isFormValid:!1},t}return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function, not "+typeof r);e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),r&&(Object.setPrototypeOf?Object.setPrototypeOf(e,r):e.__proto__=r)}(r,a.default.Component),o(r,[{key:"render",value:function(){var e=this.state,r=e.fields,t=e.errors,n=e.isFormValid,o=e.validation;return this.props.children({isFormValid:n,isFieldValid:o,fields:this.toArray(r),onChange:this.onChange,errors:t})}}]),r}();r.default=f,f.propTypes={parent:i.default.object,children:i.default.func,onPassValidation:i.default.func,fields:i.default.object}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Validator=void 0;var n=function(e){return e&&e.__esModule?e:{default:e}}(t(5));r.Validator=n.default}])); |
{ | ||
"name": "react-form-validator-component", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"main": "build/lib/index.js", | ||
@@ -43,12 +43,3 @@ "repository": "git@github.com:JDLT-Ltd/react-form-validator-component.git", | ||
}, | ||
"dependencies": {}, | ||
"keywords": [ | ||
"react", | ||
"form", | ||
"validation", | ||
"form-validation", | ||
"form validation", | ||
"react-form-validation", | ||
"react-form-validation-component" | ||
] | ||
"dependencies": {} | ||
} |
@@ -75,3 +75,4 @@ import React from 'react' | ||
const fieldValue = e.target.value | ||
const onPassValidation = this.props.onPassValidation || this.onPassValidation | ||
const onPassValidation = | ||
this.props.fields[fieldName].onPassValidation || this.props.onPassValidation || this.onPassValidation | ||
@@ -78,0 +79,0 @@ if (this.validateField(fieldName, fieldValue)) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
317
270085