@lemoncode/fonk
Advanced tools
Comparing version 1.4.0-beta.1 to 1.4.0-beta.2
@@ -114,39 +114,2 @@ 'use strict'; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
function __rest(s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
} | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
} | ||
// TODO: Better naming for this? | ||
@@ -160,7 +123,5 @@ var safeArrayLength = function safeArrayLength(collection) {return Array.isArray(collection) ? collection.length : 0;}; | ||
var safeObjectKeys = function safeObjectKeys(value) {return Boolean(value) ? Object.keys(value) : [];}; | ||
var reduceAsync = function reduceAsync(collection, callback, defaultResult) {return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {return regeneratorRuntime.wrap(function _callee2$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0:_context2.next = 2; | ||
return collection.reduce(function (promise, item, index) {return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {var result;return regeneratorRuntime.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:_context.next = 2; | ||
return promise;case 2:result = _context.sent;_context.next = 5; | ||
return callback(result, item, index);case 5:return _context.abrupt("return", _context.sent);case 6:case "end":return _context.stop();}}}, _callee);}));}, | ||
Promise.resolve(defaultResult));case 2:return _context2.abrupt("return", _context2.sent);case 3:case "end":return _context2.stop();}}}, _callee2);}));}; | ||
var reduceAsync = function reduceAsync(collection, callback, defaultResult) {return collection.reduce(function (promise, item, index) { | ||
return promise.then(function (result) {return callback(result, item, index);}); | ||
}, Promise.resolve(defaultResult));}; | ||
@@ -1308,2 +1269,29 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
function __rest(s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
} | ||
var didAllValidationsSucceeded = function didAllValidationsSucceeded(validationResults) {return validationResults.every(function (fvr) {return fvr.succeeded;});}; | ||
@@ -1591,17 +1579,15 @@ var extractErrors = function extractErrors(validationResults) {return validationResults.reduce(function (errors, _a) { | ||
var validator$5 = function validator(validatorArgs) {return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {var value, customArgs, formValidation, arrayValidationResult;return regeneratorRuntime.wrap(function _callee2$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0: | ||
value = validatorArgs.value, customArgs = validatorArgs.customArgs; | ||
formValidation = createFormValidation(customArgs);_context2.next = 4; | ||
return reduceAsync(value, function (validationResult, item) {return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {var _yield$formValidation, fieldErrors, succeeded;return regeneratorRuntime.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:_context.next = 2; | ||
return formValidation.validateForm(item);case 2:_yield$formValidation = _context.sent;fieldErrors = _yield$formValidation.fieldErrors;succeeded = _yield$formValidation.succeeded;return _context.abrupt("return", | ||
{ | ||
succeeded: validationResult.succeeded && succeeded, | ||
arrayErrors: [].concat(_toConsumableArray(validationResult.arrayErrors), [fieldErrors]) });case 6:case "end":return _context.stop();}}}, _callee);}));}, | ||
var validator$5 = function validator(validatorArgs) {var | ||
value = validatorArgs.value,customArgs = validatorArgs.customArgs; | ||
var formValidation = createFormValidation(customArgs); | ||
return reduceAsync(value, function (validationResult, item) {return formValidation.validateForm(item).then(function (_ref) {var fieldErrors = _ref.fieldErrors,succeeded = _ref.succeeded;return { | ||
succeeded: validationResult.succeeded && succeeded, | ||
arrayErrors: [].concat(_toConsumableArray(validationResult.arrayErrors), [fieldErrors]) };});}, | ||
createEmptyArrayValidationResult()).then(function (arrayValidationResult) {return { | ||
succeeded: arrayValidationResult.succeeded, | ||
type: 'ARRAY_VALIDATIONS', | ||
message: null, | ||
arrayErrors: arrayValidationResult.arrayErrors };}); | ||
createEmptyArrayValidationResult());case 4:arrayValidationResult = _context2.sent;return _context2.abrupt("return", | ||
{ | ||
succeeded: arrayValidationResult.succeeded, | ||
type: 'ARRAY_VALIDATIONS', | ||
message: null, | ||
arrayErrors: arrayValidationResult.arrayErrors });case 6:case "end":return _context2.stop();}}}, _callee2);}));}; | ||
}; | ||
@@ -1608,0 +1594,0 @@ var array = /*#__PURE__*/Object.freeze({ |
@@ -110,39 +110,2 @@ function _typeof(obj) { | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
function __rest(s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
} | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
} | ||
// TODO: Better naming for this? | ||
@@ -156,7 +119,5 @@ var safeArrayLength = function safeArrayLength(collection) {return Array.isArray(collection) ? collection.length : 0;}; | ||
var safeObjectKeys = function safeObjectKeys(value) {return Boolean(value) ? Object.keys(value) : [];}; | ||
var reduceAsync = function reduceAsync(collection, callback, defaultResult) {return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {return regeneratorRuntime.wrap(function _callee2$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0:_context2.next = 2; | ||
return collection.reduce(function (promise, item, index) {return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {var result;return regeneratorRuntime.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:_context.next = 2; | ||
return promise;case 2:result = _context.sent;_context.next = 5; | ||
return callback(result, item, index);case 5:return _context.abrupt("return", _context.sent);case 6:case "end":return _context.stop();}}}, _callee);}));}, | ||
Promise.resolve(defaultResult));case 2:return _context2.abrupt("return", _context2.sent);case 3:case "end":return _context2.stop();}}}, _callee2);}));}; | ||
var reduceAsync = function reduceAsync(collection, callback, defaultResult) {return collection.reduce(function (promise, item, index) { | ||
return promise.then(function (result) {return callback(result, item, index);}); | ||
}, Promise.resolve(defaultResult));}; | ||
@@ -1304,2 +1265,29 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
function __rest(s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
} | ||
var didAllValidationsSucceeded = function didAllValidationsSucceeded(validationResults) {return validationResults.every(function (fvr) {return fvr.succeeded;});}; | ||
@@ -1587,17 +1575,15 @@ var extractErrors = function extractErrors(validationResults) {return validationResults.reduce(function (errors, _a) { | ||
var validator$5 = function validator(validatorArgs) {return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {var value, customArgs, formValidation, arrayValidationResult;return regeneratorRuntime.wrap(function _callee2$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0: | ||
value = validatorArgs.value, customArgs = validatorArgs.customArgs; | ||
formValidation = createFormValidation(customArgs);_context2.next = 4; | ||
return reduceAsync(value, function (validationResult, item) {return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {var _yield$formValidation, fieldErrors, succeeded;return regeneratorRuntime.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:_context.next = 2; | ||
return formValidation.validateForm(item);case 2:_yield$formValidation = _context.sent;fieldErrors = _yield$formValidation.fieldErrors;succeeded = _yield$formValidation.succeeded;return _context.abrupt("return", | ||
{ | ||
succeeded: validationResult.succeeded && succeeded, | ||
arrayErrors: [].concat(_toConsumableArray(validationResult.arrayErrors), [fieldErrors]) });case 6:case "end":return _context.stop();}}}, _callee);}));}, | ||
var validator$5 = function validator(validatorArgs) {var | ||
value = validatorArgs.value,customArgs = validatorArgs.customArgs; | ||
var formValidation = createFormValidation(customArgs); | ||
return reduceAsync(value, function (validationResult, item) {return formValidation.validateForm(item).then(function (_ref) {var fieldErrors = _ref.fieldErrors,succeeded = _ref.succeeded;return { | ||
succeeded: validationResult.succeeded && succeeded, | ||
arrayErrors: [].concat(_toConsumableArray(validationResult.arrayErrors), [fieldErrors]) };});}, | ||
createEmptyArrayValidationResult()).then(function (arrayValidationResult) {return { | ||
succeeded: arrayValidationResult.succeeded, | ||
type: 'ARRAY_VALIDATIONS', | ||
message: null, | ||
arrayErrors: arrayValidationResult.arrayErrors };}); | ||
createEmptyArrayValidationResult());case 4:arrayValidationResult = _context2.sent;return _context2.abrupt("return", | ||
{ | ||
succeeded: arrayValidationResult.succeeded, | ||
type: 'ARRAY_VALIDATIONS', | ||
message: null, | ||
arrayErrors: arrayValidationResult.arrayErrors });case 6:case "end":return _context2.stop();}}}, _callee2);}));}; | ||
}; | ||
@@ -1604,0 +1590,0 @@ var array = /*#__PURE__*/Object.freeze({ |
@@ -1,2 +0,2 @@ | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e=e||self)["@lemoncode/fonk"]={})}(this,(function(e){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function t(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function n(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],n=!0,o=!1,u=void 0;try{for(var a,i=e[Symbol.iterator]();!(n=(a=i.next()).done)&&(t.push(a.value),!r||t.length!==r);n=!0);}catch(e){o=!0,u=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw u}}return t}(e,r)||u(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")} | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e=e||self)["@lemoncode/fonk"]={})}(this,(function(e){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function t(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function n(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],n=!0,o=!1,u=void 0;try{for(var a,i=e[Symbol.iterator]();!(n=(a=i.next()).done)&&(t.push(a.value),!r||t.length!==r);n=!0);}catch(e){o=!0,u=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw u}}return t}(e,r)||u(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||u(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,r){if(e){if("string"==typeof e)return a(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?a(e,r):void 0}}function a(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var i=function(e){return function(e){return Array.isArray(e)?e.length:0}(e)>0},c=function(e){return"function"==typeof e},s=function(e){return null==e},l=function(e){return e instanceof Promise},f=function(e){return Boolean(e)?Object.keys(e):[]},d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},v=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,p=/^\w*$/,y=/^\./,h=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,m=/\\(\\)?/g,g=/^\[object .+?Constructor\]$/,_="object"==r(d)&&d&&d.Object===Object&&d,b="object"==("undefined"==typeof self?"undefined":r(self))&&self&&self.Object===Object&&self,E=_||b||Function("return this")();var j,O=Array.prototype,A=Function.prototype,w=Object.prototype,S=E["__core-js_shared__"],P=(j=/[^.]+$/.exec(S&&S.keys&&S.keys.IE_PROTO||""))?"Symbol(src)_1."+j:"",x=A.toString,k=w.hasOwnProperty,V=w.toString,R=RegExp("^"+x.call(k).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),T=E.Symbol,F=O.splice,I=H(E,"Map"),M=H(Object,"create"),$=T?T.prototype:void 0,N=$?$.toString:void 0;function z(e){var r=-1,t=e?e.length:0;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}function L(e){var r=-1,t=e?e.length:0;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}function C(e){var r=-1,t=e?e.length:0;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}function D(e,r){for(var t,n,o=e.length;o--;)if((t=e[o][0])===(n=r)||t!=t&&n!=n)return o;return-1}function B(e,t){for(var n,o=0,u=(t=function(e,t){if(W(e))return!1;var n=r(e);if("number"==n||"symbol"==n||"boolean"==n||null==e||Y(e))return!0;return p.test(e)||!v.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:W(n=t)?n:Z(n)).length;null!=e&&o<u;)e=e[q(t[o++])];return o&&o==u?e:void 0}function U(e){return!(!X(e)||(r=e,P&&P in r))&&(function(e){var r=X(e)?V.call(e):"";return"[object Function]"==r||"[object GeneratorFunction]"==r}(e)||function(e){var r=!1;if(null!=e&&"function"!=typeof e.toString)try{r=!!(e+"")}catch(e){}return r}(e)?R:g).test(function(e){if(null!=e){try{return x.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var r}function G(e,t){var n,o,u=e.__data__;return("string"==(o=r(n=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?u["string"==typeof t?"string":"hash"]:u.map}function H(e,r){var t=function(e,r){return null==e?void 0:e[r]}(e,r);return U(t)?t:void 0}z.prototype.clear=function(){this.__data__=M?M(null):{}},z.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},z.prototype.get=function(e){var r=this.__data__;if(M){var t=r[e];return"__lodash_hash_undefined__"===t?void 0:t}return k.call(r,e)?r[e]:void 0},z.prototype.has=function(e){var r=this.__data__;return M?void 0!==r[e]:k.call(r,e)},z.prototype.set=function(e,r){return this.__data__[e]=M&&void 0===r?"__lodash_hash_undefined__":r,this},L.prototype.clear=function(){this.__data__=[]},L.prototype.delete=function(e){var r=this.__data__,t=D(r,e);return!(t<0)&&(t==r.length-1?r.pop():F.call(r,t,1),!0)},L.prototype.get=function(e){var r=this.__data__,t=D(r,e);return t<0?void 0:r[t][1]},L.prototype.has=function(e){return D(this.__data__,e)>-1},L.prototype.set=function(e,r){var t=this.__data__,n=D(t,e);return n<0?t.push([e,r]):t[n][1]=r,this},C.prototype.clear=function(){this.__data__={hash:new z,map:new(I||L),string:new z}},C.prototype.delete=function(e){return G(this,e).delete(e)},C.prototype.get=function(e){return G(this,e).get(e)},C.prototype.has=function(e){return G(this,e).has(e)},C.prototype.set=function(e,r){return G(this,e).set(e,r),this};var Z=Q((function(e){var r;e=null==(r=e)?"":function(e){if("string"==typeof e)return e;if(Y(e))return N?N.call(e):"";var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}(r);var t=[];return y.test(e)&&t.push(""),e.replace(h,(function(e,r,n,o){t.push(n?o.replace(m,"$1"):r||e)})),t}));function q(e){if("string"==typeof e||Y(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}function Q(e,r){if("function"!=typeof e||r&&"function"!=typeof r)throw new TypeError("Expected a function");var t=function t(){var n=arguments,o=r?r.apply(this,n):n[0],u=t.cache;if(u.has(o))return u.get(o);var a=e.apply(this,n);return t.cache=u.set(o,a),a};return t.cache=new(Q.Cache||C),t}Q.Cache=C;var W=Array.isArray;function X(e){var t=r(e);return!!e&&("object"==t||"function"==t)}function Y(e){return"symbol"==r(e)||function(e){return!!e&&"object"==r(e)}(e)&&"[object Symbol]"==V.call(e)}var J=function(e,r,t){var n=null==e?void 0:B(e,r);return void 0===n?t:n},K=function(){return{type:"",succeeded:!0,message:""}},ee=function(){return{succeeded:!0,recordErrors:{}}},re=function(e){return function(r){var t=e?e(r):{type:"",succeeded:!0,message:""};return l(t)?t:Promise.resolve(t)}},te=function(e){return function(r){var t=e?e(r):{type:"",succeeded:!0,message:""};return l(t)?t:Promise.resolve(t)}},ne=function(e){return c(e)?{validator:re(e),message:void 0,customArgs:void 0}:{validator:re(c(e.validator)?e.validator:e.validator.validator),customArgs:e.customArgs,message:e.message}},oe=function(e){return Array.isArray(e)?e.map(ne):[]},ue=function(e){var r=e instanceof Object?e:{},t=Object.entries(r).map((function(e){var r=n(e,2),t=r[0],o=r[1];return[t,oe(o)]}));return t.reduce((function(e,r){var t=n(r,2),o=t[0],u=t[1];return e[o]=u,e}),{})},ae=function(e){return c(e)?{validator:te(e),message:void 0}:{validator:te(c(e.validator)?e.validator:e.validator.validator),message:e.message}},ie=function(e){return Array.isArray(e)?e.map(ae):[]},ce=function(e){var r=e instanceof Object?e:{},t=Object.entries(r).map((function(e){var r=n(e,2),t=r[0],o=r[1];return[t,ie(o)]}));return t.reduce((function(e,r){var t=n(r,2),o=t[0],u=t[1];return e[o]=u,e}),{})},se=function(e,r){return e.arrayErrors.reduce((function(e,n,o){return Object.assign(Object.assign({},e),function(e,r,n,o){return Object.keys(n).reduce((function(e,u){return Object.assign(Object.assign({},e),t({},"".concat(r,"[").concat(o,"].").concat(u),n[u]))}),{})}(0,r,n,o))}),{})},le=function(e){return Boolean(e.arrayErrors)?se(e,e.key):{type:e.type,message:e.message,succeeded:e.succeeded}},fe=function(e){return{succeeded:e.succeeded,recordErrors:e.recordErrors,fieldErrors:(r=e.fieldErrors,Object.keys(r).reduce((function(e,n){var o=r[n],u=Boolean(o.arrayErrors)?se(o,n):t({},n,o);return Object.assign(Object.assign({},e),u)}),{}))};var r},de=function(e,r,t,n){return e.map((function(e){return n(e,r,t)}))},ve=function(e){var r=e;return e&&!s(e.succeeded)||(console.error("form-validators: One of the record validator is returning a non expected value."),r={key:"",type:"",succeeded:!0,message:""}),r},pe=function(e,r){return r.validator({values:e,message:r.message}).then(ve)},ye=function(e,r){return i(r)?function(e,r){return r.reduce((function(r,t){return r.then((function(r){return r.succeeded?pe(e,t):r}))}),pe(e,r[0]))}(e,r):Promise.resolve({key:"",type:"",succeeded:!0,message:""})},he=function(e){var r=e;return e&&!s(e.succeeded)||(console.error("form-validators: One of the field validator is returning a non expected value."),r={key:"",type:"",succeeded:!0,message:""}),r},me=function(e,r,t){return t.validator({value:e,values:r,customArgs:t.customArgs,message:t.message}).then(he)},ge=function(e,r,t){return i(t)?function(e,r,t){return t.reduce((function(t,n){return t.then((function(t){return t.succeeded?me(e,r,n):t}))}),me(e,r,t[0]))}(e,r,t):Promise.resolve({key:"",type:"",succeeded:!0,message:""})};var _e=function(e){return e.every((function(e){return e.succeeded}))},be=function(e){return e.reduce((function(e,r){var t=r.key,n= | ||
/*! ***************************************************************************** | ||
@@ -15,2 +15,3 @@ Copyright (c) Microsoft Corporation. | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */()}function o(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||u(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,r){if(e){if("string"==typeof e)return a(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?a(e,r):void 0}}function a(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function i(e,r,t,n){return new(t||(t=Promise))((function(o,u){function a(e){try{c(n.next(e))}catch(e){u(e)}}function i(e){try{c(n.throw(e))}catch(e){u(e)}}function c(e){var r;e.done?o(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(a,i)}c((n=n.apply(e,r||[])).next())}))}var c=function(e){return function(e){return Array.isArray(e)?e.length:0}(e)>0},s=function(e){return"function"==typeof e},f=function(e){return null==e},l=function(e){return e instanceof Promise},d=function(e){return Boolean(e)?Object.keys(e):[]},v=function(e,r,t){return i(void 0,void 0,void 0,regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e.reduce((function(e,t,n){return i(void 0,void 0,void 0,regeneratorRuntime.mark((function o(){var u;return regeneratorRuntime.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,e;case 2:return u=o.sent,o.next=5,r(u,t,n);case 5:return o.abrupt("return",o.sent);case 6:case"end":return o.stop()}}),o)})))}),Promise.resolve(t));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})))},p="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},m=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,h=/^\w*$/,y=/^\./,g=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,b=/\\(\\)?/g,_=/^\[object .+?Constructor\]$/,E="object"==r(p)&&p&&p.Object===Object&&p,j="object"==("undefined"==typeof self?"undefined":r(self))&&self&&self.Object===Object&&self,w=E||j||Function("return this")();var O,A=Array.prototype,S=Function.prototype,x=Object.prototype,P=w["__core-js_shared__"],R=(O=/[^.]+$/.exec(P&&P.keys&&P.keys.IE_PROTO||""))?"Symbol(src)_1."+O:"",k=S.toString,V=x.hasOwnProperty,T=x.toString,F=RegExp("^"+k.call(V).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),I=w.Symbol,M=A.splice,$=q(w,"Map"),N=q(Object,"create"),z=I?I.prototype:void 0,L=z?z.toString:void 0;function C(e){var r=-1,t=e?e.length:0;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}function D(e){var r=-1,t=e?e.length:0;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}function B(e){var r=-1,t=e?e.length:0;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}function U(e,r){for(var t,n,o=e.length;o--;)if((t=e[o][0])===(n=r)||t!=t&&n!=n)return o;return-1}function G(e,t){for(var n,o=0,u=(t=function(e,t){if(Y(e))return!1;var n=r(e);if("number"==n||"symbol"==n||"boolean"==n||null==e||K(e))return!0;return h.test(e)||!m.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:Y(n=t)?n:Q(n)).length;null!=e&&o<u;)e=e[W(t[o++])];return o&&o==u?e:void 0}function H(e){return!(!J(e)||(r=e,R&&R in r))&&(function(e){var r=J(e)?T.call(e):"";return"[object Function]"==r||"[object GeneratorFunction]"==r}(e)||function(e){var r=!1;if(null!=e&&"function"!=typeof e.toString)try{r=!!(e+"")}catch(e){}return r}(e)?F:_).test(function(e){if(null!=e){try{return k.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var r}function Z(e,t){var n,o,u=e.__data__;return("string"==(o=r(n=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?u["string"==typeof t?"string":"hash"]:u.map}function q(e,r){var t=function(e,r){return null==e?void 0:e[r]}(e,r);return H(t)?t:void 0}C.prototype.clear=function(){this.__data__=N?N(null):{}},C.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},C.prototype.get=function(e){var r=this.__data__;if(N){var t=r[e];return"__lodash_hash_undefined__"===t?void 0:t}return V.call(r,e)?r[e]:void 0},C.prototype.has=function(e){var r=this.__data__;return N?void 0!==r[e]:V.call(r,e)},C.prototype.set=function(e,r){return this.__data__[e]=N&&void 0===r?"__lodash_hash_undefined__":r,this},D.prototype.clear=function(){this.__data__=[]},D.prototype.delete=function(e){var r=this.__data__,t=U(r,e);return!(t<0)&&(t==r.length-1?r.pop():M.call(r,t,1),!0)},D.prototype.get=function(e){var r=this.__data__,t=U(r,e);return t<0?void 0:r[t][1]},D.prototype.has=function(e){return U(this.__data__,e)>-1},D.prototype.set=function(e,r){var t=this.__data__,n=U(t,e);return n<0?t.push([e,r]):t[n][1]=r,this},B.prototype.clear=function(){this.__data__={hash:new C,map:new($||D),string:new C}},B.prototype.delete=function(e){return Z(this,e).delete(e)},B.prototype.get=function(e){return Z(this,e).get(e)},B.prototype.has=function(e){return Z(this,e).has(e)},B.prototype.set=function(e,r){return Z(this,e).set(e,r),this};var Q=X((function(e){var r;e=null==(r=e)?"":function(e){if("string"==typeof e)return e;if(K(e))return L?L.call(e):"";var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}(r);var t=[];return y.test(e)&&t.push(""),e.replace(g,(function(e,r,n,o){t.push(n?o.replace(b,"$1"):r||e)})),t}));function W(e){if("string"==typeof e||K(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}function X(e,r){if("function"!=typeof e||r&&"function"!=typeof r)throw new TypeError("Expected a function");var t=function t(){var n=arguments,o=r?r.apply(this,n):n[0],u=t.cache;if(u.has(o))return u.get(o);var a=e.apply(this,n);return t.cache=u.set(o,a),a};return t.cache=new(X.Cache||B),t}X.Cache=B;var Y=Array.isArray;function J(e){var t=r(e);return!!e&&("object"==t||"function"==t)}function K(e){return"symbol"==r(e)||function(e){return!!e&&"object"==r(e)}(e)&&"[object Symbol]"==T.call(e)}var ee=function(e,r,t){var n=null==e?void 0:G(e,r);return void 0===n?t:n},re=function(){return{type:"",succeeded:!0,message:""}},te=function(){return{succeeded:!0,recordErrors:{}}},ne=function(e){return function(r){var t=e?e(r):{type:"",succeeded:!0,message:""};return l(t)?t:Promise.resolve(t)}},oe=function(e){return function(r){var t=e?e(r):{type:"",succeeded:!0,message:""};return l(t)?t:Promise.resolve(t)}},ue=function(e){return s(e)?{validator:ne(e),message:void 0,customArgs:void 0}:{validator:ne(s(e.validator)?e.validator:e.validator.validator),customArgs:e.customArgs,message:e.message}},ae=function(e){return Array.isArray(e)?e.map(ue):[]},ie=function(e){var r=e instanceof Object?e:{},t=Object.entries(r).map((function(e){var r=n(e,2),t=r[0],o=r[1];return[t,ae(o)]}));return t.reduce((function(e,r){var t=n(r,2),o=t[0],u=t[1];return e[o]=u,e}),{})},ce=function(e){return s(e)?{validator:oe(e),message:void 0}:{validator:oe(s(e.validator)?e.validator:e.validator.validator),message:e.message}},se=function(e){return Array.isArray(e)?e.map(ce):[]},fe=function(e){var r=e instanceof Object?e:{},t=Object.entries(r).map((function(e){var r=n(e,2),t=r[0],o=r[1];return[t,se(o)]}));return t.reduce((function(e,r){var t=n(r,2),o=t[0],u=t[1];return e[o]=u,e}),{})},le=function(e,r){return e.arrayErrors.reduce((function(e,n,o){return Object.assign(Object.assign({},e),function(e,r,n,o){return Object.keys(n).reduce((function(e,u){return Object.assign(Object.assign({},e),t({},"".concat(r,"[").concat(o,"].").concat(u),n[u]))}),{})}(0,r,n,o))}),{})},de=function(e){return Boolean(e.arrayErrors)?le(e,e.key):{type:e.type,message:e.message,succeeded:e.succeeded}},ve=function(e){return{succeeded:e.succeeded,recordErrors:e.recordErrors,fieldErrors:(r=e.fieldErrors,Object.keys(r).reduce((function(e,n){var o=r[n],u=Boolean(o.arrayErrors)?le(o,n):t({},n,o);return Object.assign(Object.assign({},e),u)}),{}))};var r},pe=function(e,r,t,n){return e.map((function(e){return n(e,r,t)}))},me=function(e){var r=e;return e&&!f(e.succeeded)||(console.error("form-validators: One of the record validator is returning a non expected value."),r={key:"",type:"",succeeded:!0,message:""}),r},he=function(e,r){return r.validator({values:e,message:r.message}).then(me)},ye=function(e,r){return c(r)?function(e,r){return r.reduce((function(r,t){return r.then((function(r){return r.succeeded?he(e,t):r}))}),he(e,r[0]))}(e,r):Promise.resolve({key:"",type:"",succeeded:!0,message:""})},ge=function(e){var r=e;return e&&!f(e.succeeded)||(console.error("form-validators: One of the field validator is returning a non expected value."),r={key:"",type:"",succeeded:!0,message:""}),r},be=function(e,r,t){return t.validator({value:e,values:r,customArgs:t.customArgs,message:t.message}).then(ge)},_e=function(e,r,t){return c(t)?function(e,r,t){return t.reduce((function(t,n){return t.then((function(t){return t.succeeded?be(e,r,n):t}))}),be(e,r,t[0]))}(e,r,t):Promise.resolve({key:"",type:"",succeeded:!0,message:""})},Ee=function(e){return e.every((function(e){return e.succeeded}))},je=function(e){return e.reduce((function(e,r){var t=r.key,n=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(t[n[o]]=e[n[o]])}return t}(r,["key"]);return e[t]=Object.assign({},n),e}),{})},we=function(e){var r={succeeded:!0,recordErrors:{}};return c(e)&&(r.succeeded=Ee(e),r.recordErrors=je(e)),r},Oe=function(e,r){return!f(r)&&!f(r[e])},Ae=function(e,r,t,n){return Oe(e,n)?_e(r,t,n[e]).then((function(r){return r.key=e,r})).catch((function(r){var t="Validation Exception, field: ".concat(e);throw console.error(t),r})):Promise.resolve({key:"",type:"",succeeded:!0,message:""})},Se=function(e,r,t){return Oe(e,t)?ye(r,t[e]).then((function(r){return r.key=e,r})).catch((function(r){var t="Validation Exception, record: ".concat(e);throw console.error(t),r})):Promise.resolve({key:"",type:"",succeeded:!0,message:""})},xe=function(e,r,t){var o=function(e,r,t,n){return e.map((function(e){return n(e,ee(r,e,void 0),r,t)}))}(d(r),e,r,Ae),u=pe(d(t),e,t,Se);return Promise.all(o).then((function(e){return Promise.all(u).then((function(r){return[e,r]}))})).then((function(e){var r=n(e,2);return function(e,r){var t={succeeded:!0,fieldErrors:{},recordErrors:{}};if(c(e)&&(t.succeeded=Ee(e),t.fieldErrors=je(e)),c(r)){var n=we(r);t.succeeded=t.succeeded&&n.succeeded,t.recordErrors=n.recordErrors}return t}(r[0],r[1])})).catch((function(e){throw console.error("Uncontrolled error validating records"),e}))},Pe=function e(t){var n=this;!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.fieldSchema={},this.recordSchema={},this.setupValidationSchema=function(e){if(e&&"object"===r(e)){var t=e.record,o=e.field;o&&"object"===r(o)&&(n.fieldSchema=ie(e.field)),t&&"object"===r(t)&&(n.recordSchema=fe(e.record))}else console.error("ValidationSchema must be a valid object")},this.validateField=function(e,r,t){return Ae(e,r,t,n.fieldSchema).then(de)},this.validateRecord=function(e){return function(e,r){var t=pe(d(r),e,r,Se);return Promise.all(t).then((function(e){return we(e)})).catch((function(e){throw console.error("Uncontrolled error validating records"),e}))}(e,n.recordSchema)},this.validateForm=function(e){return xe(e,n.fieldSchema,n.recordSchema).then(ve)},this.updateValidationSchema=function(e){n.setupValidationSchema(e)},this.setupValidationSchema(t)},Re=function(e){return new Pe(e)},ke=function(e,r){return e?function(e,r){var t=function(e){return e.match(/{{[^{}][\w\.]*}}/g)}(e);return Array.isArray(t)?t.reduce((function(e,t){return e.replace(t,ee(r,function(e){return e.replace(/[{}]/g,"")}(t),t))}),e):e}(e,r):""},Ve="Please fill in this mandatory field.",Te={trim:!0},Fe=function(e,r){return!!function(e){return null==e||""===e}(e)||r.test(e)},Ie="Please enter a valid email address.",Me=/^(([^<>()\[\]\\.,;:\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,}))$/,$e="Please provide a valid format.",Ne="FieldValidationError: pattern option for pattern validation is mandatory. Example: { pattern: /d+/ }.";function ze(e){var r=e.pattern;if("boolean"==typeof r||null===r)throw new Error(Ne);return function(e){return e instanceof RegExp?e:new RegExp(e)}(r)}function Le(e,r){var t=null===e.length?NaN:Number(e.length);if(isNaN(t))throw new Error(r);return t}function Ce(e,r,t){return"string"!=typeof e||t(e,r)}var De="The value provided does not fulfill min length",Be='FieldValidationError: Parameter "length" for minLength in customArgs is mandatory and should be a valid number. Example: { length: 4 }.',Ue=function(e,r){return e.length>=r},Ge="The value provided does not fulfill max length",He='FieldValidationError: Parameter "length" for maxLength in customArgs is mandatory and should be a valid number. Example: { length: 4 }.',Ze=function(e,r){return e.length<=r},qe={required:Object.freeze({__proto__:null,setErrorMessage:function(e){return Ve=e},validator:function(e){var r=e.value,t=e.customArgs,n=void 0===t?Te:t,o=e.message,u=void 0===o?Ve:o,a=function(e,r){return"string"==typeof e?function(e,r){return r?e.trim().length>0:e.length>0}(e,r):function(e){return null!=e}(e)}(r,Boolean(n.trim));return{succeeded:a,message:a?"":ke(u,n),type:"REQUIRED"}}}),email:Object.freeze({__proto__:null,setErrorMessage:function(e){return Ie=e},validator:function(e){var r=e.value,t=e.message,n=void 0===t?Ie:t,o=function(e){return Fe(e,Me)}(r);return{succeeded:o,message:o?"":n,type:"EMAIL"}}}),pattern:Object.freeze({__proto__:null,setErrorMessage:function(e){return $e=e},validator:function(e){if(!e.customArgs)throw new Error(Ne);var r=e.value,t=e.customArgs,n=void 0===t?null:t,o=e.message,u=void 0===o?$e:o,a=ze(n),i=Fe(r,a);return{succeeded:i,message:i?"":ke(u,n),type:"PATTERN"}}}),minLength:Object.freeze({__proto__:null,setErrorMessage:function(e){return De=e},validator:function(e){if(!e.customArgs)throw new Error(Be);var r=e.value,t=e.customArgs,n=void 0===t?null:t,o=e.message,u=void 0===o?De:o,a=Ce(r,Le(n,Be),Ue);return{succeeded:a,message:a?"":ke(u,n),type:"MIN_LENGTH"}}}),maxLength:Object.freeze({__proto__:null,setErrorMessage:function(e){return Ge=e},validator:function(e){if(!e.customArgs)throw new Error(He);var r=e.value,t=e.customArgs,n=void 0===t?null:t,o=e.message,u=void 0===o?Ge:o,a=Ce(r,Le(n,He),Ze);return{succeeded:a,message:a?"":ke(u,n),type:"MAX_LENGTH"}}}),array:Object.freeze({__proto__:null,validator:function(e){return i(void 0,void 0,void 0,regeneratorRuntime.mark((function r(){var t,n,u,a;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return t=e.value,n=e.customArgs,u=Re(n),r.next=4,v(t,(function(e,r){return i(void 0,void 0,void 0,regeneratorRuntime.mark((function t(){var n,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,u.validateForm(r);case 2:return n=t.sent,a=n.fieldErrors,i=n.succeeded,t.abrupt("return",{succeeded:e.succeeded&&i,arrayErrors:[].concat(o(e.arrayErrors),[a])});case 6:case"end":return t.stop()}}),t)})))}),{succeeded:!0,arrayErrors:[]});case 4:return a=r.sent,r.abrupt("return",{succeeded:a.succeeded,type:"ARRAY_VALIDATIONS",message:null,arrayErrors:a.arrayErrors});case 6:case"end":return r.stop()}}),r)})))}})};e.FormValidation=Pe,e.Validators=qe,e.createDefaultFormValidationResult=function(){return{succeeded:!0,fieldErrors:{},recordErrors:{}}},e.createDefaultRecordValidationResult=te,e.createDefaultValidationResult=re,e.createFormValidation=Re,e.parseMessageWithCustomArgs=ke,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
***************************************************************************** */ | ||
function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(t[n[o]]=e[n[o]])}return t}(r,["key"]);return e[t]=Object.assign({},n),e}),{})},Ee=function(e){var r={succeeded:!0,recordErrors:{}};return i(e)&&(r.succeeded=_e(e),r.recordErrors=be(e)),r},je=function(e,r){return!s(r)&&!s(r[e])},Oe=function(e,r,t,n){return je(e,n)?ge(r,t,n[e]).then((function(r){return r.key=e,r})).catch((function(r){var t="Validation Exception, field: ".concat(e);throw console.error(t),r})):Promise.resolve({key:"",type:"",succeeded:!0,message:""})},Ae=function(e,r,t){return je(e,t)?ye(r,t[e]).then((function(r){return r.key=e,r})).catch((function(r){var t="Validation Exception, record: ".concat(e);throw console.error(t),r})):Promise.resolve({key:"",type:"",succeeded:!0,message:""})},we=function(e,r,t){var o=function(e,r,t,n){return e.map((function(e){return n(e,J(r,e,void 0),r,t)}))}(f(r),e,r,Oe),u=de(f(t),e,t,Ae);return Promise.all(o).then((function(e){return Promise.all(u).then((function(r){return[e,r]}))})).then((function(e){var r=n(e,2);return function(e,r){var t={succeeded:!0,fieldErrors:{},recordErrors:{}};if(i(e)&&(t.succeeded=_e(e),t.fieldErrors=be(e)),i(r)){var n=Ee(r);t.succeeded=t.succeeded&&n.succeeded,t.recordErrors=n.recordErrors}return t}(r[0],r[1])})).catch((function(e){throw console.error("Uncontrolled error validating records"),e}))},Se=function e(t){var n=this;!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.fieldSchema={},this.recordSchema={},this.setupValidationSchema=function(e){if(e&&"object"===r(e)){var t=e.record,o=e.field;o&&"object"===r(o)&&(n.fieldSchema=ue(e.field)),t&&"object"===r(t)&&(n.recordSchema=ce(e.record))}else console.error("ValidationSchema must be a valid object")},this.validateField=function(e,r,t){return Oe(e,r,t,n.fieldSchema).then(le)},this.validateRecord=function(e){return function(e,r){var t=de(f(r),e,r,Ae);return Promise.all(t).then((function(e){return Ee(e)})).catch((function(e){throw console.error("Uncontrolled error validating records"),e}))}(e,n.recordSchema)},this.validateForm=function(e){return we(e,n.fieldSchema,n.recordSchema).then(fe)},this.updateValidationSchema=function(e){n.setupValidationSchema(e)},this.setupValidationSchema(t)},Pe=function(e){return new Se(e)},xe=function(e,r){return e?function(e,r){var t=function(e){return e.match(/{{[^{}][\w\.]*}}/g)}(e);return Array.isArray(t)?t.reduce((function(e,t){return e.replace(t,J(r,function(e){return e.replace(/[{}]/g,"")}(t),t))}),e):e}(e,r):""},ke="Please fill in this mandatory field.",Ve={trim:!0},Re=function(e,r){return!!function(e){return null==e||""===e}(e)||r.test(e)},Te="Please enter a valid email address.",Fe=/^(([^<>()\[\]\\.,;:\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,}))$/,Ie="Please provide a valid format.",Me="FieldValidationError: pattern option for pattern validation is mandatory. Example: { pattern: /d+/ }.";function $e(e){var r=e.pattern;if("boolean"==typeof r||null===r)throw new Error(Me);return function(e){return e instanceof RegExp?e:new RegExp(e)}(r)}function Ne(e,r){var t=null===e.length?NaN:Number(e.length);if(isNaN(t))throw new Error(r);return t}function ze(e,r,t){return"string"!=typeof e||t(e,r)}var Le="The value provided does not fulfill min length",Ce='FieldValidationError: Parameter "length" for minLength in customArgs is mandatory and should be a valid number. Example: { length: 4 }.',De=function(e,r){return e.length>=r},Be="The value provided does not fulfill max length",Ue='FieldValidationError: Parameter "length" for maxLength in customArgs is mandatory and should be a valid number. Example: { length: 4 }.',Ge=function(e,r){return e.length<=r},He={required:Object.freeze({__proto__:null,setErrorMessage:function(e){return ke=e},validator:function(e){var r=e.value,t=e.customArgs,n=void 0===t?Ve:t,o=e.message,u=void 0===o?ke:o,a=function(e,r){return"string"==typeof e?function(e,r){return r?e.trim().length>0:e.length>0}(e,r):function(e){return null!=e}(e)}(r,Boolean(n.trim));return{succeeded:a,message:a?"":xe(u,n),type:"REQUIRED"}}}),email:Object.freeze({__proto__:null,setErrorMessage:function(e){return Te=e},validator:function(e){var r=e.value,t=e.message,n=void 0===t?Te:t,o=function(e){return Re(e,Fe)}(r);return{succeeded:o,message:o?"":n,type:"EMAIL"}}}),pattern:Object.freeze({__proto__:null,setErrorMessage:function(e){return Ie=e},validator:function(e){if(!e.customArgs)throw new Error(Me);var r=e.value,t=e.customArgs,n=void 0===t?null:t,o=e.message,u=void 0===o?Ie:o,a=$e(n),i=Re(r,a);return{succeeded:i,message:i?"":xe(u,n),type:"PATTERN"}}}),minLength:Object.freeze({__proto__:null,setErrorMessage:function(e){return Le=e},validator:function(e){if(!e.customArgs)throw new Error(Ce);var r=e.value,t=e.customArgs,n=void 0===t?null:t,o=e.message,u=void 0===o?Le:o,a=ze(r,Ne(n,Ce),De);return{succeeded:a,message:a?"":xe(u,n),type:"MIN_LENGTH"}}}),maxLength:Object.freeze({__proto__:null,setErrorMessage:function(e){return Be=e},validator:function(e){if(!e.customArgs)throw new Error(Ue);var r=e.value,t=e.customArgs,n=void 0===t?null:t,o=e.message,u=void 0===o?Be:o,a=ze(r,Ne(n,Ue),Ge);return{succeeded:a,message:a?"":xe(u,n),type:"MAX_LENGTH"}}}),array:Object.freeze({__proto__:null,validator:function(e){var r,t,n,u=e.value,a=e.customArgs,i=Pe(a);return(r=u,t=function(e,r){return i.validateForm(r).then((function(r){var t=r.fieldErrors,n=r.succeeded;return{succeeded:e.succeeded&&n,arrayErrors:[].concat(o(e.arrayErrors),[t])}}))},n={succeeded:!0,arrayErrors:[]},r.reduce((function(e,r,n){return e.then((function(e){return t(e,r,n)}))}),Promise.resolve(n))).then((function(e){return{succeeded:e.succeeded,type:"ARRAY_VALIDATIONS",message:null,arrayErrors:e.arrayErrors}}))}})};e.FormValidation=Se,e.Validators=He,e.createDefaultFormValidationResult=function(){return{succeeded:!0,fieldErrors:{},recordErrors:{}}},e.createDefaultRecordValidationResult=ee,e.createDefaultValidationResult=K,e.createFormValidation=Pe,e.parseMessageWithCustomArgs=xe,Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@lemoncode/fonk", | ||
"version": "1.4.0-beta.1", | ||
"version": "1.4.0-beta.2", | ||
"description": "Form schema validator library", | ||
@@ -5,0 +5,0 @@ "main": "dist/@lemoncode/fonk.cjs.js", |
Sorry, the diff of this file is too big to display
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
213694
4625