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

validator-runner

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

validator-runner - npm Package Compare versions

Comparing version 0.0.5 to 0.1.0

2

dist/bundle.esm.js

@@ -1,2 +0,2 @@

function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(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)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),e}function _toConsumableArray(e){if(Array.isArray(e)){for(var r=0,t=new Array(e.length);r<e.length;r++)t[r]=e[r];return t}return Array.from(e)}var Validator=function(){function e(r){var t=this;_classCallCheck(this,e),this.transformToPromise=function(e,r,n,a){var o=r.validator.apply(r,_toConsumableArray(n)),i=!0;o&&o.then&&o.catch||(i=!1,o=o?Promise.resolve(o):Promise.reject(o));var l={errors:a,fieldName:e,target:n,isAsync:i};return o.then(function(e){return Object.assign(l,{promiseValue:e})},function(e){return l.errors=t.messageHandler(a,r.message,n,e),Promise.reject(Object.assign(l,{promiseValue:e}))})},this.lastValidator={},this.descriptor=r}return _createClass(e,[{key:"validateItem",value:function(e,r,t){var n,a=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{first:!0,cover:!0,concurrent:!1},i=[],l=(arguments.length>4?arguments[4]:void 0)||this.descriptor[r];if(l&&!(l.length<1))return Array.isArray(l)||(l=[l]),n=o.concurrent?Promise.all(l.map(function(t){var n=[r].concat(_toConsumableArray(t.join||[])).map(function(r){return e[r]});return a.transformToPromise(r,t,n,i).then(function(e){return e},o.first?null:function(e){return e})})):l.reduce(function(t,n){var l=[r].concat(_toConsumableArray(n.join||[])).map(function(r){return e[r]});return t.then(function(){return a.transformToPromise(r,n,l,i)},o.first?null:function(){return a.transformToPromise(r,n,l,i)})},Promise.resolve()),this.lastValidator[r]=n,n.then(function(e){return(!o.cover||a.lastValidator[r]===n)&&t&&t(i,e),e},function(e){return(!o.cover||a.lastValidator[r]===n)&&t&&t(i,e),Promise.reject(e)});t(i,{})}},{key:"validate",value:function(e,r){var t=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=!1,o={},i=[];return(n.specificField||Object.keys(this.descriptor)).forEach(function(r){i.push(t.validateItem(e,r,function(e){o[r]=e,n.fieldCallback&&n.fieldCallback(r,e)},n))}),Promise.all(i.map(function(e){return e.catch(function(e){return a=!0,e})})).then(function(){return r(o,!a),a?Promise.reject(o):o})}},{key:"messageHandler",value:function(e,r,t,n){return"function"==typeof r?e.push("".concat(r.apply(void 0,_toConsumableArray(t).concat([n]))||"Error!").trim()):e.push("".concat(r||"Error!").trim()),e}},{key:"cancelItem",value:function(e){this.lastValidator[e]=null}},{key:"cancelAll",value:function(){this.lastValidator={}}},{key:"addRule",value:function(e){this.ruleSet=Object.assign(this.ruleSet,e)}},{key:"updateRuleSet",value:function(e){this.ruleSet=e}},{key:"deleteRule",value:function(e){delete this.ruleSet[e]}}]),e}();export default Validator;
function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(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)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),e}function _toConsumableArray(e){if(Array.isArray(e)){for(var r=0,t=new Array(e.length);r<e.length;r++)t[r]=e[r];return t}return Array.from(e)}var Validator=function(){function e(r){var t=this;_classCallCheck(this,e),this.transformToPromise=function(e,r,n,a){var o=r.validator.apply(r,_toConsumableArray(n)),i=!0;o&&o.then&&o.catch||(i=!1,o=o?Promise.resolve(o):Promise.reject(o));var l={errors:a,fieldName:e,target:n,isAsync:i};return o.then(function(e){return Object.assign(l,{promiseValue:e})},function(e){return l.errors=t.messageHandler(a,r.message,n,e),Promise.reject(Object.assign(l,{promiseValue:e}))})},this.lastValidator={},this.descriptor=r}return _createClass(e,[{key:"validateItem",value:function(e,r,t){var n,a=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{traversal:!1,retention:!1,concurrent:!1},i=[],l=(arguments.length>4?arguments[4]:void 0)||this.descriptor[r];if(l&&!(l.length<1))return Array.isArray(l)||(l=[l]),n=o.concurrent?Promise.all(l.map(function(t){var n=[r].concat(_toConsumableArray(t.join||[])).map(function(r){return e[r]});return a.transformToPromise(r,t,n,i).then(function(e){return e},o.traversal?function(e){return e}:null)})):l.reduce(function(t,n){var l=[r].concat(_toConsumableArray(n.join||[])).map(function(r){return e[r]});return t.then(function(){return a.transformToPromise(r,n,l,i)},o.traversal?function(){return a.transformToPromise(r,n,l,i)}:null)},Promise.resolve()),this.lastValidator[r]=n,n.then(function(e){return(o.retention||a.lastValidator[r]===n)&&t&&t(i,e),e},function(e){return(o.retention||a.lastValidator[r]===n)&&t&&t(i,e),Promise.reject(e)});t(i,{})}},{key:"validate",value:function(e,r){var t=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=!1,o={},i=[];return(n.specificField||Object.keys(this.descriptor)).forEach(function(r){i.push(t.validateItem(e,r,function(e){o[r]=e,n.fieldCallback&&n.fieldCallback(r,e)},n))}),Promise.all(i.map(function(e){return e.catch(function(e){return a=!0,e})})).then(function(){return r(o,!a),a?Promise.reject(o):o})}},{key:"messageHandler",value:function(e,r,t,n){return"function"==typeof r?e.push("".concat(r.apply(void 0,_toConsumableArray(t).concat([n]))||"Error!").trim()):e.push("".concat(r||"Error!").trim()),e}},{key:"cancelItem",value:function(e){this.lastValidator[e]=null}},{key:"cancelAll",value:function(){this.lastValidator={}}},{key:"addRule",value:function(e){this.ruleSet=Object.assign(this.ruleSet,e)}},{key:"updateRuleSet",value:function(e){this.ruleSet=e}},{key:"deleteRule",value:function(e){delete this.ruleSet[e]}}]),e}();export default Validator;
//# sourceMappingURL=bundle.esm.js.map

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.validator=t()}(this,function(){"use strict";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)}}function t(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}return function(){function r(e){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),this.transformToPromise=function(e,r,i,o){var a=r.validator.apply(r,t(i)),u=!0;a&&a.then&&a.catch||(u=!1,a=a?Promise.resolve(a):Promise.reject(a));var c={errors:o,fieldName:e,target:i,isAsync:u};return a.then(function(e){return Object.assign(c,{promiseValue:e})},function(e){return c.errors=n.messageHandler(o,r.message,i,e),Promise.reject(Object.assign(c,{promiseValue:e}))})},this.lastValidator={},this.descriptor=e}var n,i,o;return n=r,(i=[{key:"validateItem",value:function(e,r,n){var i,o=this,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{first:!0,cover:!0,concurrent:!1},u=arguments.length>4?arguments[4]:void 0,c=[],l=u||this.descriptor[r];if(l&&!(l.length<1))return Array.isArray(l)||(l=[l]),i=a.concurrent?Promise.all(l.map(function(n){var i=[r].concat(t(n.join||[])).map(function(t){return e[t]});return o.transformToPromise(r,n,i,c).then(function(e){return e},a.first?null:function(e){return e})})):l.reduce(function(n,i){var u=[r].concat(t(i.join||[])).map(function(t){return e[t]});return n.then(function(){return o.transformToPromise(r,i,u,c)},a.first?null:function(){return o.transformToPromise(r,i,u,c)})},Promise.resolve()),this.lastValidator[r]=i,i.then(function(e){return(!a.cover||o.lastValidator[r]===i)&&n&&n(c,e),e},function(e){return(!a.cover||o.lastValidator[r]===i)&&n&&n(c,e),Promise.reject(e)});n(c,{})}},{key:"validate",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=!1,o={},a=[];return(n.specificField||Object.keys(this.descriptor)).forEach(function(t){a.push(r.validateItem(e,t,function(e){o[t]=e,n.fieldCallback&&n.fieldCallback(t,e)},n))}),Promise.all(a.map(function(e){return e.catch(function(e){return i=!0,e})})).then(function(){return t(o,!i),i?Promise.reject(o):o})}},{key:"messageHandler",value:function(e,r,n,i){return"function"==typeof r?e.push("".concat(r.apply(void 0,t(n).concat([i]))||"Error!").trim()):e.push("".concat(r||"Error!").trim()),e}},{key:"cancelItem",value:function(e){this.lastValidator[e]=null}},{key:"cancelAll",value:function(){this.lastValidator={}}},{key:"addRule",value:function(e){this.ruleSet=Object.assign(this.ruleSet,e)}},{key:"updateRuleSet",value:function(e){this.ruleSet=e}},{key:"deleteRule",value:function(e){delete this.ruleSet[e]}}])&&e(n.prototype,i),o&&e(n,o),r}()});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.validator=t()}(this,function(){"use strict";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)}}function t(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}return function(){function r(e){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),this.transformToPromise=function(e,r,i,a){var o=r.validator.apply(r,t(i)),u=!0;o&&o.then&&o.catch||(u=!1,o=o?Promise.resolve(o):Promise.reject(o));var l={errors:a,fieldName:e,target:i,isAsync:u};return o.then(function(e){return Object.assign(l,{promiseValue:e})},function(e){return l.errors=n.messageHandler(a,r.message,i,e),Promise.reject(Object.assign(l,{promiseValue:e}))})},this.lastValidator={},this.descriptor=e}var n,i,a;return n=r,(i=[{key:"validateItem",value:function(e,r,n){var i,a=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{traversal:!1,retention:!1,concurrent:!1},u=arguments.length>4?arguments[4]:void 0,l=[],c=u||this.descriptor[r];if(c&&!(c.length<1))return Array.isArray(c)||(c=[c]),i=o.concurrent?Promise.all(c.map(function(n){var i=[r].concat(t(n.join||[])).map(function(t){return e[t]});return a.transformToPromise(r,n,i,l).then(function(e){return e},o.traversal?function(e){return e}:null)})):c.reduce(function(n,i){var u=[r].concat(t(i.join||[])).map(function(t){return e[t]});return n.then(function(){return a.transformToPromise(r,i,u,l)},o.traversal?function(){return a.transformToPromise(r,i,u,l)}:null)},Promise.resolve()),this.lastValidator[r]=i,i.then(function(e){return(o.retention||a.lastValidator[r]===i)&&n&&n(l,e),e},function(e){return(o.retention||a.lastValidator[r]===i)&&n&&n(l,e),Promise.reject(e)});n(l,{})}},{key:"validate",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=!1,a={},o=[];return(n.specificField||Object.keys(this.descriptor)).forEach(function(t){o.push(r.validateItem(e,t,function(e){a[t]=e,n.fieldCallback&&n.fieldCallback(t,e)},n))}),Promise.all(o.map(function(e){return e.catch(function(e){return i=!0,e})})).then(function(){return t(a,!i),i?Promise.reject(a):a})}},{key:"messageHandler",value:function(e,r,n,i){return"function"==typeof r?e.push("".concat(r.apply(void 0,t(n).concat([i]))||"Error!").trim()):e.push("".concat(r||"Error!").trim()),e}},{key:"cancelItem",value:function(e){this.lastValidator[e]=null}},{key:"cancelAll",value:function(){this.lastValidator={}}},{key:"addRule",value:function(e){this.ruleSet=Object.assign(this.ruleSet,e)}},{key:"updateRuleSet",value:function(e){this.ruleSet=e}},{key:"deleteRule",value:function(e){delete this.ruleSet[e]}}])&&e(n.prototype,i),a&&e(n,a),r}()});
{
"name": "validator-runner",
"version": "0.0.5",
"version": "0.1.0",
"description": "Validate form asynchronous",

@@ -5,0 +5,0 @@ "main": "dist/bundle.js",

Sorry, the diff of this file is not supported yet

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