Socket
Socket
Sign inDemoInstall

@lemoncode/fonk

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lemoncode/fonk - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0-beta.1

1945

dist/@lemoncode/fonk.cjs.js

@@ -6,2 +6,4 @@ 'use strict';

function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {

@@ -26,6 +28,29 @@ _typeof = function (obj) {

function _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;
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _arrayWithHoles(arr) {

@@ -35,7 +60,8 @@ if (Array.isArray(arr)) return arr;

function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
}
function _iterableToArrayLimit(arr, i) {
if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
return;
}
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
var _arr = [];

@@ -66,19 +92,40 @@ var _n = true;

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
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 _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Copyright (c) Microsoft Corporation.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
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.
***************************************************************************** */

@@ -98,96 +145,99 @@

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?
var safeArrayLength = function safeArrayLength(collection) {
return Array.isArray(collection) ? collection.length : 0;
};
var arrayContainsEntries = function arrayContainsEntries(collection) {
return safeArrayLength(collection) > 0;
}; // https://stackoverflow.com/questions/5999998/check-if-a-variable-is-of-function-type
var safeArrayLength = function safeArrayLength(collection) {return Array.isArray(collection) ? collection.length : 0;};
var arrayContainsEntries = function arrayContainsEntries(collection) {return safeArrayLength(collection) > 0;};
// https://stackoverflow.com/questions/5999998/check-if-a-variable-is-of-function-type
var isFunction = function isFunction(v) {return typeof v === 'function';};
var isUndefinedOrNull = function isUndefinedOrNull(v) {return v === void 0 || v === null;};
var isPromise = function isPromise(value) {return value instanceof Promise;};
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 isFunction = function isFunction(v) {
return typeof v === 'function';
};
var isUndefinedOrNull = function isUndefinedOrNull(v) {
return v === void 0 || v === null;
};
var isPromise = function isPromise(value) {
return value instanceof Promise;
};
var safeObjectKeys = function safeObjectKeys(value) {
return Boolean(value) ? Object.keys(value) : [];
};
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
/**
* lodash (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="npm" -o ./`
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
* lodash (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="npm" -o ./`
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
var INFINITY = 1 / 0;
/** `Object#toString` result references. */
var funcTag = '[object Function]',
genTag = '[object GeneratorFunction]',
symbolTag = '[object Symbol]';
var funcTag = '[object Function]',
genTag = '[object GeneratorFunction]',
symbolTag = '[object Symbol]';
/** Used to match property names within property paths. */
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
reIsPlainProp = /^\w*$/,
reLeadingDot = /^\./,
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
reIsPlainProp = /^\w*$/,
reLeadingDot = /^\./,
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
/**
* Used to match `RegExp`
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
*/
* Used to match `RegExp`
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
*/
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
/** Used to match backslashes in property paths. */
var reEscapeChar = /\\(\\)?/g;
var reEscapeChar = /\\(\\)?/g;
/** Used to detect host constructors (Safari). */
var reIsHostCtor = /^\[object .+?Constructor\]$/;
var reIsHostCtor = /^\[object .+?Constructor\]$/;
/** Detect free variable `global` from Node.js. */
var freeGlobal =
_typeof(commonjsGlobal) == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
var freeGlobal = _typeof(commonjsGlobal) == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
/** Detect free variable `self`. */
var freeSelf =
(typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' && self && self.Object === Object && self;
var freeSelf = (typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
var root = freeGlobal || freeSelf || Function('return this')();
/**
* Gets the value at `key` of `object`.
*
* @private
* @param {Object} [object] The object to query.
* @param {string} key The key of the property to get.
* @returns {*} Returns the property value.
*/
* Gets the value at `key` of `object`.
*
* @private
* @param {Object} [object] The object to query.
* @param {string} key The key of the property to get.
* @returns {*} Returns the property value.
*/
function getValue(object, key) {
return object == null ? undefined : object[key];
}
/**
* Checks if `value` is a host object in IE < 9.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
*/
* Checks if `value` is a host object in IE < 9.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
*/
function isHostObject(value) {

@@ -197,3 +247,2 @@ // Many host objects are `Object` objects that can coerce to strings

var result = false;
if (value != null && typeof value.toString != 'function') {

@@ -204,62 +253,71 @@ try {

}
return result;
}
/** Used for built-in method references. */
var arrayProto = Array.prototype,
funcProto = Function.prototype,
objectProto = Object.prototype;
var arrayProto = Array.prototype,
funcProto = Function.prototype,
objectProto = Object.prototype;
/** Used to detect overreaching core-js shims. */
var coreJsData = root['__core-js_shared__'];
var coreJsData = root['__core-js_shared__'];
/** Used to detect methods masquerading as native. */
var maskSrcKey = function () {
var uid = /[^.]+$/.exec(
coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
var maskSrcKey = function () {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
return uid ? 'Symbol(src)_1.' + uid : '';
}();
/** Used to resolve the decompiled source of functions. */
var funcToString = funcProto.toString;
var funcToString = funcProto.toString;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
var objectToString = objectProto.toString;
/** Used to detect if a method is native. */
var reIsNative = RegExp(
'^' +
funcToString.
call(hasOwnProperty).
replace(reRegExpChar, '\\$&').
replace(
/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,
'$1.*?') +
var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
'$');
/** Built-in value references. */
var _Symbol = root.Symbol,
splice = arrayProto.splice;
var _Symbol = root.Symbol,
splice = arrayProto.splice;
/* Built-in method references that are verified to be native. */
var Map = getNative(root, 'Map'),
nativeCreate = getNative(Object, 'create');
var Map = getNative(root, 'Map'),
nativeCreate = getNative(Object, 'create');
/** Used to convert symbols to primitives and strings. */
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
symbolToString = symbolProto ? symbolProto.toString : undefined;
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
symbolToString = symbolProto ? symbolProto.toString : undefined;
/**
* Creates a hash object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
* Creates a hash object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function Hash(entries) {
var index = -1,
length = entries ? entries.length : 0;
length = entries ? entries.length : 0;
this.clear();
while (++index < length) {

@@ -270,43 +328,39 @@ var entry = entries[index];

}
/**
* Removes all key-value entries from the hash.
*
* @private
* @name clear
* @memberOf Hash
*/
* Removes all key-value entries from the hash.
*
* @private
* @name clear
* @memberOf Hash
*/
function hashClear() {
this.__data__ = nativeCreate ? nativeCreate(null) : {};
}
/**
* Removes `key` and its value from the hash.
*
* @private
* @name delete
* @memberOf Hash
* @param {Object} hash The hash to modify.
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
* Removes `key` and its value from the hash.
*
* @private
* @name delete
* @memberOf Hash
* @param {Object} hash The hash to modify.
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function hashDelete(key) {
return this.has(key) && delete this.__data__[key];
}
/**
* Gets the hash value for `key`.
*
* @private
* @name get
* @memberOf Hash
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
* Gets the hash value for `key`.
*
* @private
* @name get
* @memberOf Hash
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function hashGet(key) {
var data = this.__data__;
if (nativeCreate) {

@@ -316,32 +370,31 @@ var result = data[key];

}
return hasOwnProperty.call(data, key) ? data[key] : undefined;
}
/**
* Checks if a hash value for `key` exists.
*
* @private
* @name has
* @memberOf Hash
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
* Checks if a hash value for `key` exists.
*
* @private
* @name has
* @memberOf Hash
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function hashHas(key) {
var data = this.__data__;
return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
return nativeCreate ?
data[key] !== undefined :
hasOwnProperty.call(data, key);
}
/**
* Sets the hash `key` to `value`.
*
* @private
* @name set
* @memberOf Hash
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the hash instance.
*/
* Sets the hash `key` to `value`.
*
* @private
* @name set
* @memberOf Hash
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the hash instance.
*/
function hashSet(key, value) {

@@ -351,5 +404,5 @@ var data = this.__data__;

return this;
} // Add methods to `Hash`.
}
// Add methods to `Hash`.
Hash.prototype.clear = hashClear;

@@ -360,15 +413,15 @@ Hash.prototype['delete'] = hashDelete;

Hash.prototype.set = hashSet;
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function ListCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
length = entries ? entries.length : 0;
this.clear();
while (++index < length) {

@@ -379,28 +432,26 @@ var entry = entries[index];

}
/**
* Removes all key-value entries from the list cache.
*
* @private
* @name clear
* @memberOf ListCache
*/
* Removes all key-value entries from the list cache.
*
* @private
* @name clear
* @memberOf ListCache
*/
function listCacheClear() {
this.__data__ = [];
}
/**
* Removes `key` and its value from the list cache.
*
* @private
* @name delete
* @memberOf ListCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
* Removes `key` and its value from the list cache.
*
* @private
* @name delete
* @memberOf ListCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function listCacheDelete(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
index = assocIndexOf(data, key);

@@ -410,5 +461,3 @@ if (index < 0) {

}
var lastIndex = data.length - 1;
if (index == lastIndex) {

@@ -419,50 +468,47 @@ data.pop();

}
return true;
}
/**
* Gets the list cache value for `key`.
*
* @private
* @name get
* @memberOf ListCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
* Gets the list cache value for `key`.
*
* @private
* @name get
* @memberOf ListCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function listCacheGet(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
index = assocIndexOf(data, key);
return index < 0 ? undefined : data[index][1];
}
/**
* Checks if a list cache value for `key` exists.
*
* @private
* @name has
* @memberOf ListCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
* Checks if a list cache value for `key` exists.
*
* @private
* @name has
* @memberOf ListCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function listCacheHas(key) {
return assocIndexOf(this.__data__, key) > -1;
}
/**
* Sets the list cache `key` to `value`.
*
* @private
* @name set
* @memberOf ListCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the list cache instance.
*/
* Sets the list cache `key` to `value`.
*
* @private
* @name set
* @memberOf ListCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the list cache instance.
*/
function listCacheSet(key, value) {
var data = this.__data__,
index = assocIndexOf(data, key);
index = assocIndexOf(data, key);

@@ -474,7 +520,6 @@ if (index < 0) {

}
return this;
} // Add methods to `ListCache`.
}
// Add methods to `ListCache`.
ListCache.prototype.clear = listCacheClear;

@@ -485,15 +530,15 @@ ListCache.prototype['delete'] = listCacheDelete;

ListCache.prototype.set = listCacheSet;
/**
* Creates a map cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
* Creates a map cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function MapCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
length = entries ? entries.length : 0;
this.clear();
while (++index < length) {

@@ -504,11 +549,10 @@ var entry = entries[index];

}
/**
* Removes all key-value entries from the map.
*
* @private
* @name clear
* @memberOf MapCache
*/
* Removes all key-value entries from the map.
*
* @private
* @name clear
* @memberOf MapCache
*/
function mapCacheClear() {

@@ -518,65 +562,61 @@ this.__data__ = {

map: new (Map || ListCache)(),
string: new Hash()
};
string: new Hash() };
}
/**
* Removes `key` and its value from the map.
*
* @private
* @name delete
* @memberOf MapCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
* Removes `key` and its value from the map.
*
* @private
* @name delete
* @memberOf MapCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function mapCacheDelete(key) {
return getMapData(this, key)['delete'](key);
}
/**
* Gets the map value for `key`.
*
* @private
* @name get
* @memberOf MapCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
* Gets the map value for `key`.
*
* @private
* @name get
* @memberOf MapCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function mapCacheGet(key) {
return getMapData(this, key).get(key);
}
/**
* Checks if a map value for `key` exists.
*
* @private
* @name has
* @memberOf MapCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
* Checks if a map value for `key` exists.
*
* @private
* @name has
* @memberOf MapCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function mapCacheHas(key) {
return getMapData(this, key).has(key);
}
/**
* Sets the map `key` to `value`.
*
* @private
* @name set
* @memberOf MapCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the map cache instance.
*/
* Sets the map `key` to `value`.
*
* @private
* @name set
* @memberOf MapCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the map cache instance.
*/
function mapCacheSet(key, value) {
getMapData(this, key).set(key, value);
return this;
} // Add methods to `MapCache`.
}
// Add methods to `MapCache`.
MapCache.prototype.clear = mapCacheClear;

@@ -587,14 +627,13 @@ MapCache.prototype['delete'] = mapCacheDelete;

MapCache.prototype.set = mapCacheSet;
/**
* Gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} key The key to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
* Gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} key The key to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function assocIndexOf(array, key) {
var length = array.length;
while (length--) {

@@ -605,19 +644,18 @@ if (eq(array[length][0], key)) {

}
return -1;
}
/**
* The base implementation of `_.get` without support for default values.
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @returns {*} Returns the resolved value.
*/
* The base implementation of `_.get` without support for default values.
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
path = isKey(path, object) ? [path] : castPath(path);
var index = 0,
length = path.length;
length = path.length;

@@ -627,15 +665,13 @@ while (object != null && index < length) {

}
return index && index == length ? object : undefined;
}
/**
* The base implementation of `_.isNative` without bad shim checks.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function,
* else `false`.
*/
* The base implementation of `_.isNative` without bad shim checks.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function,
* else `false`.
*/
function baseIsNative(value) {

@@ -645,16 +681,15 @@ if (!isObject(value) || isMasked(value)) {

}
var pattern = isFunction$1(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
var pattern =
isFunction$1(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
return pattern.test(toSource(value));
}
/**
* The base implementation of `_.toString` which doesn't convert nullish
* values to empty strings.
*
* @private
* @param {*} value The value to process.
* @returns {string} Returns the string.
*/
* The base implementation of `_.toString` which doesn't convert nullish
* values to empty strings.
*
* @private
* @param {*} value The value to process.
* @returns {string} Returns the string.
*/
function baseToString(value) {

@@ -665,46 +700,43 @@ // Exit early for strings to avoid a performance hit in some environments.

}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : '';
}
var result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
}
/**
* Casts `value` to a path array if it's not one.
*
* @private
* @param {*} value The value to inspect.
* @returns {Array} Returns the cast property path array.
*/
* Casts `value` to a path array if it's not one.
*
* @private
* @param {*} value The value to inspect.
* @returns {Array} Returns the cast property path array.
*/
function castPath(value) {
return isArray(value) ? value : stringToPath(value);
}
/**
* Gets the data for `map`.
*
* @private
* @param {Object} map The map to query.
* @param {string} key The reference key.
* @returns {*} Returns the map data.
*/
* Gets the data for `map`.
*
* @private
* @param {Object} map The map to query.
* @param {string} key The reference key.
* @returns {*} Returns the map data.
*/
function getMapData(map, key) {
var data = map.__data__;
return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
return isKeyable(key) ?
data[typeof key == 'string' ? 'string' : 'hash'] :
data.map;
}
/**
* Gets the native function at `key` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the method to get.
* @returns {*} Returns the function if it's native, else `undefined`.
*/
* Gets the native function at `key` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the method to get.
* @returns {*} Returns the function if it's native, else `undefined`.
*/
function getNative(object, key) {

@@ -714,12 +746,11 @@ var value = getValue(object, key);

}
/**
* Checks if `value` is a property name and not a property path.
*
* @private
* @param {*} value The value to check.
* @param {Object} [object] The object to query keys on.
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
*/
* Checks if `value` is a property name and not a property path.
*
* @private
* @param {*} value The value to check.
* @param {Object} [object] The object to query keys on.
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
*/
function isKey(value, object) {

@@ -729,54 +760,61 @@ if (isArray(value)) {

}
var type = _typeof(value);
if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol(value)) {
if (
type == 'number' ||
type == 'symbol' ||
type == 'boolean' ||
value == null ||
isSymbol(value))
{
return true;
}
return (
reIsPlainProp.test(value) ||
!reIsDeepProp.test(value) ||
object != null && value in Object(object));
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
}
/**
* Checks if `value` is suitable for use as unique object key.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
*/
* Checks if `value` is suitable for use as unique object key.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
*/
function isKeyable(value) {
var type = _typeof(value);
return type == 'string' ||
type == 'number' ||
type == 'symbol' ||
type == 'boolean' ?
value !== '__proto__' :
value === null;
}
return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
}
/**
* Checks if `func` has its source masked.
*
* @private
* @param {Function} func The function to check.
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
*/
* Checks if `func` has its source masked.
*
* @private
* @param {Function} func The function to check.
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
*/
function isMasked(func) {
return !!maskSrcKey && maskSrcKey in func;
}
/**
* Converts `string` to a property path array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the property path array.
*/
* Converts `string` to a property path array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the property path array.
*/
var stringToPath = memoize(function (string) {
string = toString(string);
var result = [];
if (reLeadingDot.test(string)) {
result.push('');
}
string.replace(rePropName, function (match, number, quote, string) {

@@ -787,10 +825,10 @@ result.push(quote ? string.replace(reEscapeChar, '$1') : number || match);

});
/**
* Converts `value` to a string key if it's not a string or symbol.
*
* @private
* @param {*} value The value to inspect.
* @returns {string|symbol} Returns the key.
*/
* Converts `value` to a string key if it's not a string or symbol.
*
* @private
* @param {*} value The value to inspect.
* @returns {string|symbol} Returns the key.
*/
function toKey(value) {

@@ -800,15 +838,13 @@ if (typeof value == 'string' || isSymbol(value)) {

}
var result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
}
/**
* Converts `func` to its source code.
*
* @private
* @param {Function} func The function to process.
* @returns {string} Returns the source code.
*/
* Converts `func` to its source code.
*
* @private
* @param {Function} func The function to process.
* @returns {string} Returns the source code.
*/
function toSource(func) {

@@ -819,3 +855,2 @@ if (func != null) {

} catch (e) {}
try {

@@ -825,60 +860,60 @@ return func + '';

}
return '';
}
/**
* Creates a function that memoizes the result of `func`. If `resolver` is
* provided, it determines the cache key for storing the result based on the
* arguments provided to the memoized function. By default, the first argument
* provided to the memoized function is used as the map cache key. The `func`
* is invoked with the `this` binding of the memoized function.
*
* **Note:** The cache is exposed as the `cache` property on the memoized
* function. Its creation may be customized by replacing the `_.memoize.Cache`
* constructor with one whose instances implement the
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
* method interface of `delete`, `get`, `has`, and `set`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to have its output memoized.
* @param {Function} [resolver] The function to resolve the cache key.
* @returns {Function} Returns the new memoized function.
* @example
*
* var object = { 'a': 1, 'b': 2 };
* var other = { 'c': 3, 'd': 4 };
*
* var values = _.memoize(_.values);
* values(object);
* // => [1, 2]
*
* values(other);
* // => [3, 4]
*
* object.a = 2;
* values(object);
* // => [1, 2]
*
* // Modify the result cache.
* values.cache.set(object, ['a', 'b']);
* values(object);
* // => ['a', 'b']
*
* // Replace `_.memoize.Cache`.
* _.memoize.Cache = WeakMap;
*/
* Creates a function that memoizes the result of `func`. If `resolver` is
* provided, it determines the cache key for storing the result based on the
* arguments provided to the memoized function. By default, the first argument
* provided to the memoized function is used as the map cache key. The `func`
* is invoked with the `this` binding of the memoized function.
*
* **Note:** The cache is exposed as the `cache` property on the memoized
* function. Its creation may be customized by replacing the `_.memoize.Cache`
* constructor with one whose instances implement the
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
* method interface of `delete`, `get`, `has`, and `set`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to have its output memoized.
* @param {Function} [resolver] The function to resolve the cache key.
* @returns {Function} Returns the new memoized function.
* @example
*
* var object = { 'a': 1, 'b': 2 };
* var other = { 'c': 3, 'd': 4 };
*
* var values = _.memoize(_.values);
* values(object);
* // => [1, 2]
*
* values(other);
* // => [3, 4]
*
* object.a = 2;
* values(object);
* // => [1, 2]
*
* // Modify the result cache.
* values.cache.set(object, ['a', 'b']);
* values(object);
* // => ['a', 'b']
*
* // Replace `_.memoize.Cache`.
* _.memoize.Cache = WeakMap;
*/
function memoize(func, resolver) {
if (typeof func != 'function' || resolver && typeof resolver != 'function') {
if (
typeof func != 'function' ||
resolver && typeof resolver != 'function')
{
throw new TypeError(FUNC_ERROR_TEXT);
}
var memoized = function memoized() {
var args = arguments,
key = resolver ? resolver.apply(this, args) : args[0],
cache = memoized.cache;
key = resolver ? resolver.apply(this, args) : args[0],
cache = memoized.cache;

@@ -888,3 +923,2 @@ if (cache.has(key)) {

}
var result = func.apply(this, args);

@@ -894,89 +928,87 @@ memoized.cache = cache.set(key, result);

};
memoized.cache = new (memoize.Cache || MapCache)();
return memoized;
} // Assign cache to `_.memoize`.
}
// Assign cache to `_.memoize`.
memoize.Cache = MapCache;
memoize.Cache = MapCache;
/**
* Performs a
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* comparison between two values to determine if they are equivalent.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.eq(object, object);
* // => true
*
* _.eq(object, other);
* // => false
*
* _.eq('a', 'a');
* // => true
*
* _.eq('a', Object('a'));
* // => false
*
* _.eq(NaN, NaN);
* // => true
*/
* Performs a
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* comparison between two values to determine if they are equivalent.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.eq(object, object);
* // => true
*
* _.eq(object, other);
* // => false
*
* _.eq('a', 'a');
* // => true
*
* _.eq('a', Object('a'));
* // => false
*
* _.eq(NaN, NaN);
* // => true
*/
function eq(value, other) {
return value === other || value !== value && other !== other;
}
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/
var isArray = Array.isArray;
var isArray = Array.isArray;
/**
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
* _.isFunction(/abc/);
* // => false
*/
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
* _.isFunction(/abc/);
* // => false
*/
function isFunction$1(value) {

@@ -988,138 +1020,135 @@ // The use of `Object#toString` avoids issues with the `typeof` operator

}
/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
function isObject(value) {
var type = _typeof(value);
return !!value && (type == 'object' || type == 'function');
}
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return !!value && _typeof(value) == 'object';
}
/**
* Checks if `value` is classified as a `Symbol` primitive or object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
* // => true
*
* _.isSymbol('abc');
* // => false
*/
* Checks if `value` is classified as a `Symbol` primitive or object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
* // => true
*
* _.isSymbol('abc');
* // => false
*/
function isSymbol(value) {
return (
_typeof(value) == 'symbol' ||
isObjectLike(value) && objectToString.call(value) == symbolTag);
}
function isSymbol(value) {
return _typeof(value) == 'symbol' || isObjectLike(value) && objectToString.call(value) == symbolTag;
}
/**
* Converts `value` to a string. An empty string is returned for `null`
* and `undefined` values. The sign of `-0` is preserved.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to process.
* @returns {string} Returns the string.
* @example
*
* _.toString(null);
* // => ''
*
* _.toString(-0);
* // => '-0'
*
* _.toString([1, 2, 3]);
* // => '1,2,3'
*/
* Converts `value` to a string. An empty string is returned for `null`
* and `undefined` values. The sign of `-0` is preserved.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to process.
* @returns {string} Returns the string.
* @example
*
* _.toString(null);
* // => ''
*
* _.toString(-0);
* // => '-0'
*
* _.toString([1, 2, 3]);
* // => '1,2,3'
*/
function toString(value) {
return value == null ? '' : baseToString(value);
}
/**
* Gets the value at `path` of `object`. If the resolved value is
* `undefined`, the `defaultValue` is returned in its place.
*
* @static
* @memberOf _
* @since 3.7.0
* @category Object
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
* @returns {*} Returns the resolved value.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
*
* _.get(object, 'a[0].b.c');
* // => 3
*
* _.get(object, ['a', '0', 'b', 'c']);
* // => 3
*
* _.get(object, 'a.b.c', 'default');
* // => 'default'
*/
* Gets the value at `path` of `object`. If the resolved value is
* `undefined`, the `defaultValue` is returned in its place.
*
* @static
* @memberOf _
* @since 3.7.0
* @category Object
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
* @returns {*} Returns the resolved value.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
*
* _.get(object, 'a[0].b.c');
* // => 3
*
* _.get(object, ['a', '0', 'b', 'c']);
* // => 3
*
* _.get(object, 'a.b.c', 'default');
* // => 'default'
*/
function get(object, path, defaultValue) {

@@ -1132,134 +1161,129 @@ var result = object == null ? undefined : baseGet(object, path);

var createDefaultValidationResult = function createDefaultValidationResult() {
return {
var createDefaultValidationResult = function createDefaultValidationResult() {return {
type: '',
succeeded: true,
message: ''
};
};
var createDefaultInternalValidationResult = function createDefaultInternalValidationResult() {
return {
message: '' };};
var createDefaultInternalValidationResult = function createDefaultInternalValidationResult() {return {
key: '',
type: '',
succeeded: true,
message: ''
};
};
var createDefaultRecordValidationResult = function createDefaultRecordValidationResult() {
return {
message: '' };};
var createDefaultRecordValidationResult = function createDefaultRecordValidationResult() {return {
succeeded: true,
recordErrors: {}
};
};
var createDefaultFormValidationResult = function createDefaultFormValidationResult() {
return {
recordErrors: {} };};
var createDefaultFormValidationResult = function createDefaultFormValidationResult() {return {
succeeded: true,
fieldErrors: {},
recordErrors: {}
};
};
recordErrors: {} };};
var convertFieldValidationToAsyncIfNeeded = function convertFieldValidationToAsyncIfNeeded(validation) {
return function (fieldValidatorArgs) {
var result = validation ? validation(fieldValidatorArgs) : createDefaultValidationResult();
var createDefaultInternalFormValidationResult = function createDefaultInternalFormValidationResult() {return {
succeeded: true,
fieldErrors: {},
recordErrors: {} };};
// Sugar we admit both flavors syncrhonous and asynchronous validators
var convertFieldValidationToAsyncIfNeeded = function convertFieldValidationToAsyncIfNeeded(validation) {return function (fieldValidatorArgs) {
var result = validation ?
validation(fieldValidatorArgs) :
createDefaultValidationResult();
return isPromise(result) ? result : Promise.resolve(result);
};
};
var convertRecordValidationToAsyncIfNeeded = function convertRecordValidationToAsyncIfNeeded(validation) {
return function (recordValidatorArgs) {
var result = validation ? validation(recordValidatorArgs) : createDefaultValidationResult();
};};
var convertRecordValidationToAsyncIfNeeded = function convertRecordValidationToAsyncIfNeeded(validation) {return function (recordValidatorArgs) {
var result = validation ?
validation(recordValidatorArgs) :
createDefaultValidationResult();
return isPromise(result) ? result : Promise.resolve(result);
};
};
};};
var mapToInternalFieldValidation = function mapToInternalFieldValidation(fieldValidation) {
return isFunction(fieldValidation) ? {
var mapToInternalFieldValidation = function mapToInternalFieldValidation(fieldValidation) {return isFunction(fieldValidation) ?
{
validator: convertFieldValidationToAsyncIfNeeded(fieldValidation),
message: void 0,
customArgs: void 0
} : {
validator: convertFieldValidationToAsyncIfNeeded(isFunction(fieldValidation.validator) ? fieldValidation.validator : fieldValidation.validator.validator),
customArgs: void 0 } :
{
validator: convertFieldValidationToAsyncIfNeeded(isFunction(fieldValidation.validator) ?
fieldValidation.validator :
fieldValidation.validator.validator),
customArgs: fieldValidation.customArgs,
message: fieldValidation.message
};
};
message: fieldValidation.message };};
var mapToInternalValidationCollection = function mapToInternalValidationCollection(fieldValidations) {
return Array.isArray(fieldValidations) ? fieldValidations.map(mapToInternalFieldValidation) : [];
};
var buildIntertalSchema = function buildIntertalSchema(internalSchema) {
return internalSchema.reduce(function (internalFieldValidations, _ref) {
var _ref2 = _slicedToArray(_ref, 2),
fieldId = _ref2[0],
fieldValidations = _ref2[1];
var mapToInternalValidationCollection = function mapToInternalValidationCollection(fieldValidations) {return Array.isArray(fieldValidations) ?
fieldValidations.map(mapToInternalFieldValidation) :
[];};
var buildIntertalSchema = function buildIntertalSchema(internalSchema) {return internalSchema.reduce(function (internalFieldValidations, _ref) {var _ref2 = _slicedToArray(_ref, 2),fieldId = _ref2[0],fieldValidations = _ref2[1];
internalFieldValidations[fieldId] = fieldValidations;
return internalFieldValidations;
}, {});
};
}, {});};
var mapToInternalFieldValidationSchema = function mapToInternalFieldValidationSchema(fieldValidationSchema) {
var validationSchema = fieldValidationSchema instanceof Object ? fieldValidationSchema : {};
var internalFieldValidations = Object.entries(validationSchema).map(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 2),
fielId = _ref4[0],
fieldValidations = _ref4[1];
var internalFieldValidations = Object.entries(validationSchema).map(function (_ref3) {var _ref4 = _slicedToArray(_ref3, 2),fielId = _ref4[0],fieldValidations = _ref4[1];return [
fielId,
mapToInternalValidationCollection(fieldValidations)];});
return [fielId, mapToInternalValidationCollection(fieldValidations)];
});
return buildIntertalSchema(internalFieldValidations);
};
var mapToInternalRecordValidation = function mapToInternalRecordValidation(recordValidation) {
return isFunction(recordValidation) ? {
var mapToInternalRecordValidation = function mapToInternalRecordValidation(recordValidation) {return isFunction(recordValidation) ?
{
validator: convertRecordValidationToAsyncIfNeeded(recordValidation),
message: void 0
} : {
validator: convertRecordValidationToAsyncIfNeeded(isFunction(recordValidation.validator) ? recordValidation.validator : recordValidation.validator.validator),
message: recordValidation.message
};
};
message: void 0 } :
var mapToInternalValidationCollection$1 = function mapToInternalValidationCollection(recordValidations) {
return Array.isArray(recordValidations) ? recordValidations.map(mapToInternalRecordValidation) : [];
};
{
validator: convertRecordValidationToAsyncIfNeeded(isFunction(recordValidation.validator) ?
recordValidation.validator :
recordValidation.validator.validator),
message: recordValidation.message };};
var buildIntertalSchema$1 = function buildIntertalSchema(internalSchema) {
return internalSchema.reduce(function (internalRecordValidations, _ref) {
var _ref2 = _slicedToArray(_ref, 2),
recordId = _ref2[0],
recordValidations = _ref2[1];
var mapToInternalValidationCollection$1 = function mapToInternalValidationCollection(recordValidations) {return Array.isArray(recordValidations) ?
recordValidations.map(mapToInternalRecordValidation) :
[];};
var buildIntertalSchema$1 = function buildIntertalSchema(internalSchema) {return internalSchema.reduce(function (internalRecordValidations, _ref) {var _ref2 = _slicedToArray(_ref, 2),recordId = _ref2[0],recordValidations = _ref2[1];
internalRecordValidations[recordId] = recordValidations;
return internalRecordValidations;
}, {});
};
}, {});};
var mapToInternalRecordValidationSchema = function mapToInternalRecordValidationSchema(recordValidationSchema) {
var validationSchema = recordValidationSchema instanceof Object ? recordValidationSchema : {};
var internalRecordValidations = Object.entries(validationSchema).map(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 2),
fielId = _ref4[0],
recordValidations = _ref4[1];
var internalRecordValidations = Object.entries(validationSchema).map(function (_ref3) {var _ref4 = _slicedToArray(_ref3, 2),fielId = _ref4[0],recordValidations = _ref4[1];return [
fielId,
mapToInternalValidationCollection$1(recordValidations)];});
return [fielId, mapToInternalValidationCollection$1(recordValidations)];
});
return buildIntertalSchema$1(internalRecordValidations);
};
var fireAllFieldsValidations = function fireAllFieldsValidations(fieldIds, values, schema, validateField) {
return fieldIds.map(function (fieldId) {
return validateField(fieldId, get_1(values, fieldId, undefined), values, schema);
});
var renameFieldNameKeys = function renameFieldNameKeys(internalValidationResult, fieldKey, fieldErrors, index) {
var fieldNames = Object.keys(fieldErrors);
return fieldNames.reduce(function (result, fieldName) {return Object.assign(Object.assign({}, result), _defineProperty({}, "".concat(fieldKey, "[").concat(index, "].").concat(fieldName), fieldErrors[fieldName]));}, {});
};
var fireAllRecordsValidations = function fireAllRecordsValidations(recordIds, values, schema, validateRecord) {
return recordIds.map(function (recordId) {
return validateRecord(recordId, values, schema);
});
var mapArrayErrorListToValidationResult = function mapArrayErrorListToValidationResult(internalValidationResult, fieldKey) {return internalValidationResult.arrayErrors.reduce(function (validationResult, fieldErrors, index) {return Object.assign(Object.assign({}, validationResult), renameFieldNameKeys(internalValidationResult, fieldKey, fieldErrors, index));}, {});};
var mapInternalValidationResultToValidationResult = function mapInternalValidationResultToValidationResult(internalValidationResult) {return Boolean(internalValidationResult.arrayErrors) ?
mapArrayErrorListToValidationResult(internalValidationResult, internalValidationResult.key) :
{
type: internalValidationResult.type,
message: internalValidationResult.message,
succeeded: internalValidationResult.succeeded };};
var mapInternalFieldErrorsToFieldErrors = function mapInternalFieldErrorsToFieldErrors(internalFieldErrors) {return Object.keys(internalFieldErrors).reduce(function (fieldErrors, field) {
var validationResult = internalFieldErrors[field];
var fieldValidationResult = Boolean(validationResult.arrayErrors) ?
mapArrayErrorListToValidationResult(validationResult, field) : _defineProperty({},
field, validationResult);
return Object.assign(Object.assign({}, fieldErrors), fieldValidationResult);
}, {});};
var mapInternalFormValidationResultToFormValidationResult = function mapInternalFormValidationResultToFormValidationResult(internalFormValidationResult) {
return {
succeeded: internalFormValidationResult.succeeded,
recordErrors: internalFormValidationResult.recordErrors,
fieldErrors: mapInternalFieldErrorsToFieldErrors(internalFormValidationResult.fieldErrors) };
};
var fireAllFieldsValidations = function fireAllFieldsValidations(fieldIds, values, schema, validateField) {return fieldIds.map(function (fieldId) {return validateField(fieldId, get_1(values, fieldId, undefined), values, schema);});};
var fireAllRecordsValidations = function fireAllRecordsValidations(recordIds, values, schema, validateRecord) {return recordIds.map(function (recordId) {return validateRecord(recordId, values, schema);});};
var checkValidationResult = function checkValidationResult(validationResult) {
var result = validationResult;
if (!validationResult || isUndefinedOrNull(validationResult.succeeded)) {

@@ -1270,31 +1294,22 @@ // show a console error, warn the user one of his validators is not well formed

}
return result;
};
var fireValidation = function fireValidation(values, internalRecordValidation) {return internalRecordValidation.
validator({
values: values,
message: internalRecordValidation.message }).
var fireValidation = function fireValidation(values, internalRecordValidation) {
return internalRecordValidation.validator({
values: values,
message: internalRecordValidation.message
}).then(checkValidationResult);
}; // Sequentially resolve promises with reduce: https://css-tricks.com/why-using-reduce-to-sequentially-resolve-promises-works/
then(checkValidationResult);};
// Sequentially resolve promises with reduce: https://css-tricks.com/why-using-reduce-to-sequentially-resolve-promises-works/
// Example run promises until one succeeds: https://gist.github.com/greggman/0b6eafb335de4bbb557c
var iterateValidationsUntilFailOrAllSucceeded = function iterateValidationsUntilFailOrAllSucceeded(values, internalRecordValidations) {return internalRecordValidations.reduce(function (result, next) {return result.then(function (validationResult) {return validationResult.succeeded ?
fireValidation(values, next) :
validationResult;});}, fireValidation(values, internalRecordValidations[0]) // Initial reduce value
);};
var fireSingleRecordValidations = function fireSingleRecordValidations(values, internalRecordValidations) {return arrayContainsEntries(internalRecordValidations) ?
iterateValidationsUntilFailOrAllSucceeded(values, internalRecordValidations) :
Promise.resolve(createDefaultInternalValidationResult());};
var iterateValidationsUntilFailOrAllSucceeded = function iterateValidationsUntilFailOrAllSucceeded(values, internalRecordValidations) {
return internalRecordValidations.reduce(function (result, next) {
return result.then(function (validationResult) {
return validationResult.succeeded ? fireValidation(values, next) : validationResult;
});
}, fireValidation(values, internalRecordValidations[0]) // Initial reduce value
);
};
var fireSingleRecordValidations = function fireSingleRecordValidations(values, internalRecordValidations) {
return arrayContainsEntries(internalRecordValidations) ? iterateValidationsUntilFailOrAllSucceeded(values, internalRecordValidations) : Promise.resolve(createDefaultInternalValidationResult());
};
var checkValidationResult$1 = function checkValidationResult(validationResult) {
var result = validationResult;
if (!validationResult || isUndefinedOrNull(validationResult.succeeded)) {

@@ -1305,49 +1320,30 @@ // show a console error, warn the user one of his validators is not well formed

}
return result;
};
var fireValidation$1 = function fireValidation(value, values, internalFieldValidation) {
return internalFieldValidation.validator({
var fireValidation$1 = function fireValidation(value, values, internalFieldValidation) {return internalFieldValidation.
validator({
value: value,
values: values,
customArgs: internalFieldValidation.customArgs,
message: internalFieldValidation.message
}).then(checkValidationResult$1);
}; // Sequentially resolve promises with reduce: https://css-tricks.com/why-using-reduce-to-sequentially-resolve-promises-works/
message: internalFieldValidation.message }).
then(checkValidationResult$1);};
// Sequentially resolve promises with reduce: https://css-tricks.com/why-using-reduce-to-sequentially-resolve-promises-works/
// Example run promises until one succeeds: https://gist.github.com/greggman/0b6eafb335de4bbb557c
var iterateValidationsUntilFailOrAllSucceeded$1 = function iterateValidationsUntilFailOrAllSucceeded(value, values, internalFieldValidations) {return internalFieldValidations.reduce(function (result, next) {return result.then(function (validationResult) {return validationResult.succeeded ?
fireValidation$1(value, values, next) :
validationResult;});}, fireValidation$1(value, values, internalFieldValidations[0]) // Initial reduce value
);};
var fireSingleFieldValidations = function fireSingleFieldValidations(value, values, internalFieldValidations) {return arrayContainsEntries(internalFieldValidations) ?
iterateValidationsUntilFailOrAllSucceeded$1(value, values, internalFieldValidations) :
Promise.resolve(createDefaultInternalValidationResult());};
var iterateValidationsUntilFailOrAllSucceeded$1 = function iterateValidationsUntilFailOrAllSucceeded(value, values, internalFieldValidations) {
return internalFieldValidations.reduce(function (result, next) {
return result.then(function (validationResult) {
return validationResult.succeeded ? fireValidation$1(value, values, next) : validationResult;
});
}, fireValidation$1(value, values, internalFieldValidations[0]) // Initial reduce value
);
};
var fireSingleFieldValidations = function fireSingleFieldValidations(value, values, internalFieldValidations) {
return arrayContainsEntries(internalFieldValidations) ? iterateValidationsUntilFailOrAllSucceeded$1(value, values, internalFieldValidations) : Promise.resolve(createDefaultInternalValidationResult());
};
var didAllValidationsSucceeded = function didAllValidationsSucceeded(validationResults) {
return validationResults.every(function (fvr) {
return fvr.succeeded;
});
};
var extractErrors = function extractErrors(validationResults) {
return validationResults.reduce(function (errors, _a) {
var key = _a.key,
validationResult = __rest(_a, ["key"]);
var didAllValidationsSucceeded = function didAllValidationsSucceeded(validationResults) {return validationResults.every(function (fvr) {return fvr.succeeded;});};
var extractErrors = function extractErrors(validationResults) {return validationResults.reduce(function (errors, _a) {
var key = _a.key,validationResult = __rest(_a, ["key"]);
errors[key] = Object.assign({}, validationResult);
return errors;
}, {});
};
}, {});};
var buildRecordValidationResult = function buildRecordValidationResult(validationResults) {
var recordValidationResult = createDefaultRecordValidationResult();
if (arrayContainsEntries(validationResults)) {

@@ -1357,8 +1353,6 @@ recordValidationResult.succeeded = didAllValidationsSucceeded(validationResults);

}
return recordValidationResult;
};
var buildFormValidationResult = function buildFormValidationResult(fieldValidationResults, recordValidationResults) {
var formValidationResult = createDefaultFormValidationResult();
var formValidationResult = createDefaultInternalFormValidationResult();
if (arrayContainsEntries(fieldValidationResults)) {

@@ -1368,43 +1362,41 @@ formValidationResult.succeeded = didAllValidationsSucceeded(fieldValidationResults);

}
if (arrayContainsEntries(recordValidationResults)) {
var recordResults = buildRecordValidationResult(recordValidationResults);
formValidationResult.succeeded = formValidationResult.succeeded && recordResults.succeeded;
formValidationResult.succeeded =
formValidationResult.succeeded && recordResults.succeeded;
formValidationResult.recordErrors = recordResults.recordErrors;
}
return formValidationResult;
};
var isIdInSchema = function isIdInSchema(fieldId, schema) {
return !isUndefinedOrNull(schema) && !isUndefinedOrNull(schema[fieldId]);
};
var validateField = function validateField(fieldId, value, values, schema) {
return !isIdInSchema(fieldId, schema) ? Promise.resolve(createDefaultInternalValidationResult()) : fireSingleFieldValidations(value, values, schema[fieldId]).then(function (validationResult) {
var isIdInSchema = function isIdInSchema(fieldId, schema) {return !isUndefinedOrNull(schema) && !isUndefinedOrNull(schema[fieldId]);};
var validateField = function validateField(fieldId, value, values, schema) {return !isIdInSchema(fieldId, schema) ?
Promise.resolve(createDefaultInternalValidationResult()) :
fireSingleFieldValidations(value, values, schema[fieldId]).
then(function (validationResult) {
validationResult.key = fieldId;
return validationResult;
})["catch"](function (error) {
})["catch"](
function (error) {
var message = "Validation Exception, field: ".concat(fieldId);
console.error(message);
throw error;
});
};
var validateSingleRecord = function validateSingleRecord(recordId, values, schema) {
return !isIdInSchema(recordId, schema) ? Promise.resolve(createDefaultInternalValidationResult()) : fireSingleRecordValidations(values, schema[recordId]).then(function (validationResult) {
});};
var validateSingleRecord = function validateSingleRecord(recordId, values, schema) {return !isIdInSchema(recordId, schema) ?
Promise.resolve(createDefaultInternalValidationResult()) :
fireSingleRecordValidations(values, schema[recordId]).
then(function (validationResult) {
validationResult.key = recordId;
return validationResult;
})["catch"](function (error) {
})["catch"](
function (error) {
var message = "Validation Exception, record: ".concat(recordId);
console.error(message);
throw error;
});
};
});};
var validateRecord = function validateRecord(values, schema) {
var promiseValidationResults = fireAllRecordsValidations(safeObjectKeys(schema), values, schema, validateSingleRecord);
return Promise.all(promiseValidationResults).then(function (validationResults) {
return buildRecordValidationResult(validationResults);
})["catch"](function (error) {
return Promise.all(promiseValidationResults).
then(function (validationResults) {return buildRecordValidationResult(validationResults);})["catch"](
function (error) {
var message = 'Uncontrolled error validating records';

@@ -1418,13 +1410,9 @@ console.error(message);

var promiseRecordValidationResults = fireAllRecordsValidations(safeObjectKeys(recordSchema), values, recordSchema, validateSingleRecord);
return Promise.all(promiseFieldValidationResults).then(function (fieldValidationResults) {
return Promise.all(promiseRecordValidationResults).then(function (recordValidationResults) {
return [fieldValidationResults, recordValidationResults];
});
}).then(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
fieldValidationResults = _ref2[0],
recordValidationResults = _ref2[1];
return Promise.all(promiseFieldValidationResults).
then(function (fieldValidationResults) {return Promise.all(promiseRecordValidationResults).then(function (recordValidationResults) {return [
fieldValidationResults,
recordValidationResults];});}).
return buildFormValidationResult(fieldValidationResults, recordValidationResults);
})["catch"](function (error) {
then(function (_ref) {var _ref2 = _slicedToArray(_ref, 2),fieldValidationResults = _ref2[0],recordValidationResults = _ref2[1];return buildFormValidationResult(fieldValidationResults, recordValidationResults);})["catch"](
function (error) {
var message = 'Uncontrolled error validating records';

@@ -1436,69 +1424,39 @@ console.error(message);

var FormValidation = function FormValidation(validationSchema) {
var _this = this;
_classCallCheck(this, FormValidation);
var FormValidation =
function FormValidation(validationSchema) {var _this = this;_classCallCheck(this, FormValidation);
this.fieldSchema = {};
this.recordSchema = {};
this.setupValidationSchema = function (validationSchema) {
if (validationSchema && _typeof(validationSchema) === 'object') {
var record = validationSchema.record,
field = validationSchema.field;
if (validationSchema && _typeof(validationSchema) === 'object') {var
record = validationSchema.record,field = validationSchema.field;
if (field && _typeof(field) === 'object') {
_this.fieldSchema = mapToInternalFieldValidationSchema(validationSchema.field);
}
if (record && _typeof(record) === 'object') {
_this.recordSchema = mapToInternalRecordValidationSchema(validationSchema.record);
}
} else {
} else
{
console.error('ValidationSchema must be a valid object');
}
};
this.validateField = function (fieldId, value, values) {
return validateField(fieldId, value, values, _this.fieldSchema).then(function (_a) {
var key = _a.key,
validationResult = __rest(_a, ["key"]);
return Object.assign({}, validationResult);
});
};
this.validateRecord = function (values) {
return validateRecord(values, _this.recordSchema);
};
this.validateForm = function (values) {
return validateForm(values, _this.fieldSchema, _this.recordSchema);
};
this.validateField = function (fieldId, value, values) {return validateField(fieldId, value, values, _this.fieldSchema).then(mapInternalValidationResultToValidationResult);};
this.validateRecord = function (values) {return validateRecord(values, _this.recordSchema);};
this.validateForm = function (values) {return validateForm(values, _this.fieldSchema, _this.recordSchema).then(mapInternalFormValidationResultToFormValidationResult);};
this.updateValidationSchema = function (validationSchema) {
_this.setupValidationSchema(validationSchema);
};
this.setupValidationSchema(validationSchema);
};
var createFormValidation = function createFormValidation(validationSchema) {
return new FormValidation(validationSchema);
};
var getArgsToParse = function getArgsToParse(message) {
return message.match(/{{[^{}][\w\.]*}}/g);
};
var createFormValidation = function createFormValidation(validationSchema) {return new FormValidation(validationSchema);};
var getArgPath = function getArgPath(arg) {
return arg.replace(/[{}]/g, '');
};
var getArgsToParse = function getArgsToParse(message) {return message.match(/{{[^{}][\w\.]*}}/g);};
var getArgPath = function getArgPath(arg) {return arg.replace(/[{}]/g, '');};
var parseMessage = function parseMessage(message, customArgs) {
var parsableArgs = getArgsToParse(message);
return Array.isArray(parsableArgs) ? parsableArgs.reduce(function (customMessage, arg) {
return customMessage.replace(arg, get_1(customArgs, getArgPath(arg), arg));
}, message) : message;
return Array.isArray(parsableArgs) ?
parsableArgs.reduce(function (customMessage, arg) {return customMessage.replace(arg, get_1(customArgs, getArgPath(arg), arg));}, message) :
message;
};
var parseMessageWithCustomArgs = function parseMessageWithCustomArgs(message, customArgs) {

@@ -1510,33 +1468,19 @@ return message ? parseMessage(message, customArgs) : '';

var defaultMessage = 'Please fill in this mandatory field.';
var setErrorMessage = function setErrorMessage(message) {
return defaultMessage = message;
};
var DEFAULT_PARAMS = {
trim: true
};
var isStringValid = function isStringValid(value, trim) {
return trim ? value.trim().length > 0 : value.length > 0;
};
var isNonStringValid = function isNonStringValid(value) {
return value !== void 0 && value !== null;
};
var isValidField = function isValidField(value, trim) {
return typeof value === 'string' ? isStringValid(value, trim) : isNonStringValid(value);
};
var validator = function validator(fieldValidatorArgs) {
var value = fieldValidatorArgs.value,
_fieldValidatorArgs$c = fieldValidatorArgs.customArgs,
customArgs = _fieldValidatorArgs$c === void 0 ? DEFAULT_PARAMS : _fieldValidatorArgs$c,
_fieldValidatorArgs$m = fieldValidatorArgs.message,
message = _fieldValidatorArgs$m === void 0 ? defaultMessage : _fieldValidatorArgs$m;
var setErrorMessage = function setErrorMessage(message) {return defaultMessage = message;};
var DEFAULT_PARAMS = { trim: true };
var isStringValid = function isStringValid(value, trim) {return trim ? value.trim().length > 0 : value.length > 0;};
var isNonStringValid = function isNonStringValid(value) {return value !== void 0 && value !== null;};
var isValidField = function isValidField(value, trim) {return typeof value === 'string' ?
isStringValid(value, trim) :
isNonStringValid(value);};
var validator = function validator(fieldValidatorArgs) {var
value = fieldValidatorArgs.value,_fieldValidatorArgs$c = fieldValidatorArgs.customArgs,customArgs = _fieldValidatorArgs$c === void 0 ? DEFAULT_PARAMS : _fieldValidatorArgs$c,_fieldValidatorArgs$m = fieldValidatorArgs.message,message = _fieldValidatorArgs$m === void 0 ? defaultMessage : _fieldValidatorArgs$m;
var succeeded = isValidField(value, Boolean(customArgs.trim));
return {
succeeded: succeeded,
message: succeeded ? '' : parseMessageWithCustomArgs(message, customArgs),
type: VALIDATOR_TYPE
};
message: succeeded ?
'' :
parseMessageWithCustomArgs(message, customArgs),
type: VALIDATOR_TYPE };
};

@@ -1550,26 +1494,13 @@

var isEmptyValue = function isEmptyValue(value) {
return value === null || value === undefined || value === '';
};
var isEmptyValue = function isEmptyValue(value) {return value === null || value === undefined || value === '';};
var isValidPattern = function isValidPattern(value, pattern) {return isEmptyValue(value) ? true : pattern.test(value);};
var isValidPattern = function isValidPattern(value, pattern) {
return isEmptyValue(value) ? true : pattern.test(value);
};
var VALIDATOR_TYPE$1 = 'EMAIL';
var defaultMessage$1 = 'Please enter a valid email address.';
var setErrorMessage$1 = function setErrorMessage(message) {
return defaultMessage$1 = message;
}; // RegExp from http://emailregex.com
var setErrorMessage$1 = function setErrorMessage(message) {return defaultMessage$1 = message;};
// RegExp from http://emailregex.com
var EMAIL_PATTERN = /^(([^<>()\[\]\\.,;:\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,}))$/;
var isValidField$1 = function isValidField(value) {
return isValidPattern(value, EMAIL_PATTERN);
};
var validator$1 = function validator(fieldValidatorArgs) {
var value = fieldValidatorArgs.value,
_fieldValidatorArgs$m = fieldValidatorArgs.message,
message = _fieldValidatorArgs$m === void 0 ? defaultMessage$1 : _fieldValidatorArgs$m;
var isValidField$1 = function isValidField(value) {return isValidPattern(value, EMAIL_PATTERN);};
var validator$1 = function validator(fieldValidatorArgs) {var
value = fieldValidatorArgs.value,_fieldValidatorArgs$m = fieldValidatorArgs.message,message = _fieldValidatorArgs$m === void 0 ? defaultMessage$1 : _fieldValidatorArgs$m;
var succeeded = isValidField$1(value);

@@ -1579,4 +1510,4 @@ return {

message: succeeded ? '' : message,
type: VALIDATOR_TYPE$1
};
type: VALIDATOR_TYPE$1 };
};

@@ -1592,15 +1523,9 @@

var defaultMessage$2 = 'Please provide a valid format.';
var setErrorMessage$2 = function setErrorMessage(message) {
return defaultMessage$2 = message;
};
var setErrorMessage$2 = function setErrorMessage(message) {return defaultMessage$2 = message;};
var BAD_PARAMETER = 'FieldValidationError: pattern option for pattern validation is mandatory. Example: { pattern: /d+/ }.';
var DEFAULT_PARAMS$1 = null;
function getRegExp(pattern) {
return pattern instanceof RegExp ? pattern : new RegExp(pattern);
}
function parsePattern(_ref) {
var pattern = _ref.pattern;
function parsePattern(_ref) {var pattern = _ref.pattern;
// Avoid RegExp like /true/ /false/ and /null/ without an explicit "true", "false" or "null"

@@ -1610,16 +1535,9 @@ if (typeof pattern === 'boolean' || pattern === null) {

}
return getRegExp(pattern);
}
var validator$2 = function validator(fieldValidatorArgs) {
if (!fieldValidatorArgs.customArgs) {
throw new Error(BAD_PARAMETER);
}
var value = fieldValidatorArgs.value,
_fieldValidatorArgs$c = fieldValidatorArgs.customArgs,
customArgs = _fieldValidatorArgs$c === void 0 ? DEFAULT_PARAMS$1 : _fieldValidatorArgs$c,
_fieldValidatorArgs$m = fieldValidatorArgs.message,
message = _fieldValidatorArgs$m === void 0 ? defaultMessage$2 : _fieldValidatorArgs$m;
}var
value = fieldValidatorArgs.value,_fieldValidatorArgs$c = fieldValidatorArgs.customArgs,customArgs = _fieldValidatorArgs$c === void 0 ? DEFAULT_PARAMS$1 : _fieldValidatorArgs$c,_fieldValidatorArgs$m = fieldValidatorArgs.message,message = _fieldValidatorArgs$m === void 0 ? defaultMessage$2 : _fieldValidatorArgs$m;
var pattern = parsePattern(customArgs);

@@ -1629,5 +1547,7 @@ var succeeded = isValidPattern(value, pattern);

succeeded: succeeded,
message: succeeded ? '' : parseMessageWithCustomArgs(message, customArgs),
type: VALIDATOR_TYPE$2
};
message: succeeded ?
'' :
parseMessageWithCustomArgs(message, customArgs),
type: VALIDATOR_TYPE$2 };
};

@@ -1643,7 +1563,5 @@

var length = customParams.length === null ? NaN : Number(customParams.length);
if (isNaN(length)) {
throw new Error(errorMessage);
}
return length;

@@ -1658,22 +1576,11 @@ }

var defaultMessage$3 = 'The value provided does not fulfill min length';
var setErrorMessage$3 = function setErrorMessage(message) {
return defaultMessage$3 = message;
};
var setErrorMessage$3 = function setErrorMessage(message) {return defaultMessage$3 = message;};
var BAD_PARAMETER$1 = 'FieldValidationError: Parameter "length" for minLength in customArgs is mandatory and should be a valid number. Example: { length: 4 }.';
var DEFAULT_PARAMS$2 = null;
var isStringLengthValid = function isStringLengthValid(value, length) {
return value.length >= length;
};
var isStringLengthValid = function isStringLengthValid(value, length) {return value.length >= length;};
var validator$3 = function validator(fieldValidatorArgs) {
if (!fieldValidatorArgs.customArgs) {
throw new Error(BAD_PARAMETER$1);
}
var value = fieldValidatorArgs.value,
_fieldValidatorArgs$c = fieldValidatorArgs.customArgs,
customArgs = _fieldValidatorArgs$c === void 0 ? DEFAULT_PARAMS$2 : _fieldValidatorArgs$c,
_fieldValidatorArgs$m = fieldValidatorArgs.message,
message = _fieldValidatorArgs$m === void 0 ? defaultMessage$3 : _fieldValidatorArgs$m;
}var
value = fieldValidatorArgs.value,_fieldValidatorArgs$c = fieldValidatorArgs.customArgs,customArgs = _fieldValidatorArgs$c === void 0 ? DEFAULT_PARAMS$2 : _fieldValidatorArgs$c,_fieldValidatorArgs$m = fieldValidatorArgs.message,message = _fieldValidatorArgs$m === void 0 ? defaultMessage$3 : _fieldValidatorArgs$m;
var length = parseLengthParams(customArgs, BAD_PARAMETER$1);

@@ -1683,5 +1590,7 @@ var succeeded = isLengthValid(value, length, isStringLengthValid);

succeeded: succeeded,
message: succeeded ? '' : parseMessageWithCustomArgs(message, customArgs),
type: VALIDATOR_TYPE$3
};
message: succeeded ?
'' :
parseMessageWithCustomArgs(message, customArgs),
type: VALIDATOR_TYPE$3 };
};

@@ -1697,22 +1606,11 @@

var defaultMessage$4 = 'The value provided does not fulfill max length';
var setErrorMessage$4 = function setErrorMessage(message) {
return defaultMessage$4 = message;
};
var setErrorMessage$4 = function setErrorMessage(message) {return defaultMessage$4 = message;};
var BAD_PARAMETER$2 = 'FieldValidationError: Parameter "length" for maxLength in customArgs is mandatory and should be a valid number. Example: { length: 4 }.';
var DEFAULT_PARAMS$3 = null;
var isStringLengthValid$1 = function isStringLengthValid(value, length) {
return value.length <= length;
};
var isStringLengthValid$1 = function isStringLengthValid(value, length) {return value.length <= length;};
var validator$4 = function validator(fieldValidatorArgs) {
if (!fieldValidatorArgs.customArgs) {
throw new Error(BAD_PARAMETER$2);
}
var value = fieldValidatorArgs.value,
_fieldValidatorArgs$c = fieldValidatorArgs.customArgs,
customArgs = _fieldValidatorArgs$c === void 0 ? DEFAULT_PARAMS$3 : _fieldValidatorArgs$c,
_fieldValidatorArgs$m = fieldValidatorArgs.message,
message = _fieldValidatorArgs$m === void 0 ? defaultMessage$4 : _fieldValidatorArgs$m;
}var
value = fieldValidatorArgs.value,_fieldValidatorArgs$c = fieldValidatorArgs.customArgs,customArgs = _fieldValidatorArgs$c === void 0 ? DEFAULT_PARAMS$3 : _fieldValidatorArgs$c,_fieldValidatorArgs$m = fieldValidatorArgs.message,message = _fieldValidatorArgs$m === void 0 ? defaultMessage$4 : _fieldValidatorArgs$m;
var length = parseLengthParams(customArgs, BAD_PARAMETER$2);

@@ -1722,5 +1620,7 @@ var succeeded = isLengthValid(value, length, isStringLengthValid$1);

succeeded: succeeded,
message: succeeded ? '' : parseMessageWithCustomArgs(message, customArgs),
type: VALIDATOR_TYPE$4
};
message: succeeded ?
'' :
parseMessageWithCustomArgs(message, customArgs),
type: VALIDATOR_TYPE$4 };
};

@@ -1734,10 +1634,29 @@

var index = {
required: required,
email: email,
pattern: pattern,
minLength: minLength,
maxLength: maxLength
};
var createEmptyArrayValidationResult = function createEmptyArrayValidationResult() {return {
succeeded: true,
arrayErrors: [] };};
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);}));},
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);}));};
var array = /*#__PURE__*/Object.freeze({
__proto__: null,
validator: validator$5
});
var index = { required: required, email: email, pattern: pattern, minLength: minLength, maxLength: maxLength, array: array };
exports.FormValidation = FormValidation;

@@ -1744,0 +1663,0 @@ exports.Validators = index;

function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {

@@ -21,6 +23,29 @@ _typeof = function (obj) {

function _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;
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _arrayWithHoles(arr) {

@@ -30,7 +55,8 @@ if (Array.isArray(arr)) return arr;

function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
}
function _iterableToArrayLimit(arr, i) {
if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
return;
}
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
var _arr = [];

@@ -61,19 +87,40 @@ var _n = true;

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
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 _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Copyright (c) Microsoft Corporation.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
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.
***************************************************************************** */

@@ -93,96 +140,99 @@

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?
var safeArrayLength = function safeArrayLength(collection) {
return Array.isArray(collection) ? collection.length : 0;
};
var arrayContainsEntries = function arrayContainsEntries(collection) {
return safeArrayLength(collection) > 0;
}; // https://stackoverflow.com/questions/5999998/check-if-a-variable-is-of-function-type
var safeArrayLength = function safeArrayLength(collection) {return Array.isArray(collection) ? collection.length : 0;};
var arrayContainsEntries = function arrayContainsEntries(collection) {return safeArrayLength(collection) > 0;};
// https://stackoverflow.com/questions/5999998/check-if-a-variable-is-of-function-type
var isFunction = function isFunction(v) {return typeof v === 'function';};
var isUndefinedOrNull = function isUndefinedOrNull(v) {return v === void 0 || v === null;};
var isPromise = function isPromise(value) {return value instanceof Promise;};
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 isFunction = function isFunction(v) {
return typeof v === 'function';
};
var isUndefinedOrNull = function isUndefinedOrNull(v) {
return v === void 0 || v === null;
};
var isPromise = function isPromise(value) {
return value instanceof Promise;
};
var safeObjectKeys = function safeObjectKeys(value) {
return Boolean(value) ? Object.keys(value) : [];
};
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
/**
* lodash (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="npm" -o ./`
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
* lodash (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="npm" -o ./`
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
var INFINITY = 1 / 0;
/** `Object#toString` result references. */
var funcTag = '[object Function]',
genTag = '[object GeneratorFunction]',
symbolTag = '[object Symbol]';
var funcTag = '[object Function]',
genTag = '[object GeneratorFunction]',
symbolTag = '[object Symbol]';
/** Used to match property names within property paths. */
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
reIsPlainProp = /^\w*$/,
reLeadingDot = /^\./,
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
reIsPlainProp = /^\w*$/,
reLeadingDot = /^\./,
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
/**
* Used to match `RegExp`
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
*/
* Used to match `RegExp`
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
*/
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
/** Used to match backslashes in property paths. */
var reEscapeChar = /\\(\\)?/g;
var reEscapeChar = /\\(\\)?/g;
/** Used to detect host constructors (Safari). */
var reIsHostCtor = /^\[object .+?Constructor\]$/;
var reIsHostCtor = /^\[object .+?Constructor\]$/;
/** Detect free variable `global` from Node.js. */
var freeGlobal =
_typeof(commonjsGlobal) == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
var freeGlobal = _typeof(commonjsGlobal) == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
/** Detect free variable `self`. */
var freeSelf =
(typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' && self && self.Object === Object && self;
var freeSelf = (typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
var root = freeGlobal || freeSelf || Function('return this')();
/**
* Gets the value at `key` of `object`.
*
* @private
* @param {Object} [object] The object to query.
* @param {string} key The key of the property to get.
* @returns {*} Returns the property value.
*/
* Gets the value at `key` of `object`.
*
* @private
* @param {Object} [object] The object to query.
* @param {string} key The key of the property to get.
* @returns {*} Returns the property value.
*/
function getValue(object, key) {
return object == null ? undefined : object[key];
}
/**
* Checks if `value` is a host object in IE < 9.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
*/
* Checks if `value` is a host object in IE < 9.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
*/
function isHostObject(value) {

@@ -192,3 +242,2 @@ // Many host objects are `Object` objects that can coerce to strings

var result = false;
if (value != null && typeof value.toString != 'function') {

@@ -199,62 +248,71 @@ try {

}
return result;
}
/** Used for built-in method references. */
var arrayProto = Array.prototype,
funcProto = Function.prototype,
objectProto = Object.prototype;
var arrayProto = Array.prototype,
funcProto = Function.prototype,
objectProto = Object.prototype;
/** Used to detect overreaching core-js shims. */
var coreJsData = root['__core-js_shared__'];
var coreJsData = root['__core-js_shared__'];
/** Used to detect methods masquerading as native. */
var maskSrcKey = function () {
var uid = /[^.]+$/.exec(
coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
var maskSrcKey = function () {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
return uid ? 'Symbol(src)_1.' + uid : '';
}();
/** Used to resolve the decompiled source of functions. */
var funcToString = funcProto.toString;
var funcToString = funcProto.toString;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
var objectToString = objectProto.toString;
/** Used to detect if a method is native. */
var reIsNative = RegExp(
'^' +
funcToString.
call(hasOwnProperty).
replace(reRegExpChar, '\\$&').
replace(
/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,
'$1.*?') +
var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
'$');
/** Built-in value references. */
var _Symbol = root.Symbol,
splice = arrayProto.splice;
var _Symbol = root.Symbol,
splice = arrayProto.splice;
/* Built-in method references that are verified to be native. */
var Map = getNative(root, 'Map'),
nativeCreate = getNative(Object, 'create');
var Map = getNative(root, 'Map'),
nativeCreate = getNative(Object, 'create');
/** Used to convert symbols to primitives and strings. */
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
symbolToString = symbolProto ? symbolProto.toString : undefined;
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
symbolToString = symbolProto ? symbolProto.toString : undefined;
/**
* Creates a hash object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
* Creates a hash object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function Hash(entries) {
var index = -1,
length = entries ? entries.length : 0;
length = entries ? entries.length : 0;
this.clear();
while (++index < length) {

@@ -265,43 +323,39 @@ var entry = entries[index];

}
/**
* Removes all key-value entries from the hash.
*
* @private
* @name clear
* @memberOf Hash
*/
* Removes all key-value entries from the hash.
*
* @private
* @name clear
* @memberOf Hash
*/
function hashClear() {
this.__data__ = nativeCreate ? nativeCreate(null) : {};
}
/**
* Removes `key` and its value from the hash.
*
* @private
* @name delete
* @memberOf Hash
* @param {Object} hash The hash to modify.
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
* Removes `key` and its value from the hash.
*
* @private
* @name delete
* @memberOf Hash
* @param {Object} hash The hash to modify.
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function hashDelete(key) {
return this.has(key) && delete this.__data__[key];
}
/**
* Gets the hash value for `key`.
*
* @private
* @name get
* @memberOf Hash
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
* Gets the hash value for `key`.
*
* @private
* @name get
* @memberOf Hash
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function hashGet(key) {
var data = this.__data__;
if (nativeCreate) {

@@ -311,32 +365,31 @@ var result = data[key];

}
return hasOwnProperty.call(data, key) ? data[key] : undefined;
}
/**
* Checks if a hash value for `key` exists.
*
* @private
* @name has
* @memberOf Hash
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
* Checks if a hash value for `key` exists.
*
* @private
* @name has
* @memberOf Hash
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function hashHas(key) {
var data = this.__data__;
return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
return nativeCreate ?
data[key] !== undefined :
hasOwnProperty.call(data, key);
}
/**
* Sets the hash `key` to `value`.
*
* @private
* @name set
* @memberOf Hash
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the hash instance.
*/
* Sets the hash `key` to `value`.
*
* @private
* @name set
* @memberOf Hash
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the hash instance.
*/
function hashSet(key, value) {

@@ -346,5 +399,5 @@ var data = this.__data__;

return this;
} // Add methods to `Hash`.
}
// Add methods to `Hash`.
Hash.prototype.clear = hashClear;

@@ -355,15 +408,15 @@ Hash.prototype['delete'] = hashDelete;

Hash.prototype.set = hashSet;
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function ListCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
length = entries ? entries.length : 0;
this.clear();
while (++index < length) {

@@ -374,28 +427,26 @@ var entry = entries[index];

}
/**
* Removes all key-value entries from the list cache.
*
* @private
* @name clear
* @memberOf ListCache
*/
* Removes all key-value entries from the list cache.
*
* @private
* @name clear
* @memberOf ListCache
*/
function listCacheClear() {
this.__data__ = [];
}
/**
* Removes `key` and its value from the list cache.
*
* @private
* @name delete
* @memberOf ListCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
* Removes `key` and its value from the list cache.
*
* @private
* @name delete
* @memberOf ListCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function listCacheDelete(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
index = assocIndexOf(data, key);

@@ -405,5 +456,3 @@ if (index < 0) {

}
var lastIndex = data.length - 1;
if (index == lastIndex) {

@@ -414,50 +463,47 @@ data.pop();

}
return true;
}
/**
* Gets the list cache value for `key`.
*
* @private
* @name get
* @memberOf ListCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
* Gets the list cache value for `key`.
*
* @private
* @name get
* @memberOf ListCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function listCacheGet(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
index = assocIndexOf(data, key);
return index < 0 ? undefined : data[index][1];
}
/**
* Checks if a list cache value for `key` exists.
*
* @private
* @name has
* @memberOf ListCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
* Checks if a list cache value for `key` exists.
*
* @private
* @name has
* @memberOf ListCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function listCacheHas(key) {
return assocIndexOf(this.__data__, key) > -1;
}
/**
* Sets the list cache `key` to `value`.
*
* @private
* @name set
* @memberOf ListCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the list cache instance.
*/
* Sets the list cache `key` to `value`.
*
* @private
* @name set
* @memberOf ListCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the list cache instance.
*/
function listCacheSet(key, value) {
var data = this.__data__,
index = assocIndexOf(data, key);
index = assocIndexOf(data, key);

@@ -469,7 +515,6 @@ if (index < 0) {

}
return this;
} // Add methods to `ListCache`.
}
// Add methods to `ListCache`.
ListCache.prototype.clear = listCacheClear;

@@ -480,15 +525,15 @@ ListCache.prototype['delete'] = listCacheDelete;

ListCache.prototype.set = listCacheSet;
/**
* Creates a map cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
* Creates a map cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function MapCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
length = entries ? entries.length : 0;
this.clear();
while (++index < length) {

@@ -499,11 +544,10 @@ var entry = entries[index];

}
/**
* Removes all key-value entries from the map.
*
* @private
* @name clear
* @memberOf MapCache
*/
* Removes all key-value entries from the map.
*
* @private
* @name clear
* @memberOf MapCache
*/
function mapCacheClear() {

@@ -513,65 +557,61 @@ this.__data__ = {

map: new (Map || ListCache)(),
string: new Hash()
};
string: new Hash() };
}
/**
* Removes `key` and its value from the map.
*
* @private
* @name delete
* @memberOf MapCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
* Removes `key` and its value from the map.
*
* @private
* @name delete
* @memberOf MapCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function mapCacheDelete(key) {
return getMapData(this, key)['delete'](key);
}
/**
* Gets the map value for `key`.
*
* @private
* @name get
* @memberOf MapCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
* Gets the map value for `key`.
*
* @private
* @name get
* @memberOf MapCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function mapCacheGet(key) {
return getMapData(this, key).get(key);
}
/**
* Checks if a map value for `key` exists.
*
* @private
* @name has
* @memberOf MapCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
* Checks if a map value for `key` exists.
*
* @private
* @name has
* @memberOf MapCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function mapCacheHas(key) {
return getMapData(this, key).has(key);
}
/**
* Sets the map `key` to `value`.
*
* @private
* @name set
* @memberOf MapCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the map cache instance.
*/
* Sets the map `key` to `value`.
*
* @private
* @name set
* @memberOf MapCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the map cache instance.
*/
function mapCacheSet(key, value) {
getMapData(this, key).set(key, value);
return this;
} // Add methods to `MapCache`.
}
// Add methods to `MapCache`.
MapCache.prototype.clear = mapCacheClear;

@@ -582,14 +622,13 @@ MapCache.prototype['delete'] = mapCacheDelete;

MapCache.prototype.set = mapCacheSet;
/**
* Gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} key The key to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
* Gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} key The key to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function assocIndexOf(array, key) {
var length = array.length;
while (length--) {

@@ -600,19 +639,18 @@ if (eq(array[length][0], key)) {

}
return -1;
}
/**
* The base implementation of `_.get` without support for default values.
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @returns {*} Returns the resolved value.
*/
* The base implementation of `_.get` without support for default values.
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
path = isKey(path, object) ? [path] : castPath(path);
var index = 0,
length = path.length;
length = path.length;

@@ -622,15 +660,13 @@ while (object != null && index < length) {

}
return index && index == length ? object : undefined;
}
/**
* The base implementation of `_.isNative` without bad shim checks.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function,
* else `false`.
*/
* The base implementation of `_.isNative` without bad shim checks.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function,
* else `false`.
*/
function baseIsNative(value) {

@@ -640,16 +676,15 @@ if (!isObject(value) || isMasked(value)) {

}
var pattern = isFunction$1(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
var pattern =
isFunction$1(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
return pattern.test(toSource(value));
}
/**
* The base implementation of `_.toString` which doesn't convert nullish
* values to empty strings.
*
* @private
* @param {*} value The value to process.
* @returns {string} Returns the string.
*/
* The base implementation of `_.toString` which doesn't convert nullish
* values to empty strings.
*
* @private
* @param {*} value The value to process.
* @returns {string} Returns the string.
*/
function baseToString(value) {

@@ -660,46 +695,43 @@ // Exit early for strings to avoid a performance hit in some environments.

}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : '';
}
var result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
}
/**
* Casts `value` to a path array if it's not one.
*
* @private
* @param {*} value The value to inspect.
* @returns {Array} Returns the cast property path array.
*/
* Casts `value` to a path array if it's not one.
*
* @private
* @param {*} value The value to inspect.
* @returns {Array} Returns the cast property path array.
*/
function castPath(value) {
return isArray(value) ? value : stringToPath(value);
}
/**
* Gets the data for `map`.
*
* @private
* @param {Object} map The map to query.
* @param {string} key The reference key.
* @returns {*} Returns the map data.
*/
* Gets the data for `map`.
*
* @private
* @param {Object} map The map to query.
* @param {string} key The reference key.
* @returns {*} Returns the map data.
*/
function getMapData(map, key) {
var data = map.__data__;
return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
return isKeyable(key) ?
data[typeof key == 'string' ? 'string' : 'hash'] :
data.map;
}
/**
* Gets the native function at `key` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the method to get.
* @returns {*} Returns the function if it's native, else `undefined`.
*/
* Gets the native function at `key` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the method to get.
* @returns {*} Returns the function if it's native, else `undefined`.
*/
function getNative(object, key) {

@@ -709,12 +741,11 @@ var value = getValue(object, key);

}
/**
* Checks if `value` is a property name and not a property path.
*
* @private
* @param {*} value The value to check.
* @param {Object} [object] The object to query keys on.
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
*/
* Checks if `value` is a property name and not a property path.
*
* @private
* @param {*} value The value to check.
* @param {Object} [object] The object to query keys on.
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
*/
function isKey(value, object) {

@@ -724,54 +755,61 @@ if (isArray(value)) {

}
var type = _typeof(value);
if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol(value)) {
if (
type == 'number' ||
type == 'symbol' ||
type == 'boolean' ||
value == null ||
isSymbol(value))
{
return true;
}
return (
reIsPlainProp.test(value) ||
!reIsDeepProp.test(value) ||
object != null && value in Object(object));
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
}
/**
* Checks if `value` is suitable for use as unique object key.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
*/
* Checks if `value` is suitable for use as unique object key.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
*/
function isKeyable(value) {
var type = _typeof(value);
return type == 'string' ||
type == 'number' ||
type == 'symbol' ||
type == 'boolean' ?
value !== '__proto__' :
value === null;
}
return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
}
/**
* Checks if `func` has its source masked.
*
* @private
* @param {Function} func The function to check.
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
*/
* Checks if `func` has its source masked.
*
* @private
* @param {Function} func The function to check.
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
*/
function isMasked(func) {
return !!maskSrcKey && maskSrcKey in func;
}
/**
* Converts `string` to a property path array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the property path array.
*/
* Converts `string` to a property path array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the property path array.
*/
var stringToPath = memoize(function (string) {
string = toString(string);
var result = [];
if (reLeadingDot.test(string)) {
result.push('');
}
string.replace(rePropName, function (match, number, quote, string) {

@@ -782,10 +820,10 @@ result.push(quote ? string.replace(reEscapeChar, '$1') : number || match);

});
/**
* Converts `value` to a string key if it's not a string or symbol.
*
* @private
* @param {*} value The value to inspect.
* @returns {string|symbol} Returns the key.
*/
* Converts `value` to a string key if it's not a string or symbol.
*
* @private
* @param {*} value The value to inspect.
* @returns {string|symbol} Returns the key.
*/
function toKey(value) {

@@ -795,15 +833,13 @@ if (typeof value == 'string' || isSymbol(value)) {

}
var result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
}
/**
* Converts `func` to its source code.
*
* @private
* @param {Function} func The function to process.
* @returns {string} Returns the source code.
*/
* Converts `func` to its source code.
*
* @private
* @param {Function} func The function to process.
* @returns {string} Returns the source code.
*/
function toSource(func) {

@@ -814,3 +850,2 @@ if (func != null) {

} catch (e) {}
try {

@@ -820,60 +855,60 @@ return func + '';

}
return '';
}
/**
* Creates a function that memoizes the result of `func`. If `resolver` is
* provided, it determines the cache key for storing the result based on the
* arguments provided to the memoized function. By default, the first argument
* provided to the memoized function is used as the map cache key. The `func`
* is invoked with the `this` binding of the memoized function.
*
* **Note:** The cache is exposed as the `cache` property on the memoized
* function. Its creation may be customized by replacing the `_.memoize.Cache`
* constructor with one whose instances implement the
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
* method interface of `delete`, `get`, `has`, and `set`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to have its output memoized.
* @param {Function} [resolver] The function to resolve the cache key.
* @returns {Function} Returns the new memoized function.
* @example
*
* var object = { 'a': 1, 'b': 2 };
* var other = { 'c': 3, 'd': 4 };
*
* var values = _.memoize(_.values);
* values(object);
* // => [1, 2]
*
* values(other);
* // => [3, 4]
*
* object.a = 2;
* values(object);
* // => [1, 2]
*
* // Modify the result cache.
* values.cache.set(object, ['a', 'b']);
* values(object);
* // => ['a', 'b']
*
* // Replace `_.memoize.Cache`.
* _.memoize.Cache = WeakMap;
*/
* Creates a function that memoizes the result of `func`. If `resolver` is
* provided, it determines the cache key for storing the result based on the
* arguments provided to the memoized function. By default, the first argument
* provided to the memoized function is used as the map cache key. The `func`
* is invoked with the `this` binding of the memoized function.
*
* **Note:** The cache is exposed as the `cache` property on the memoized
* function. Its creation may be customized by replacing the `_.memoize.Cache`
* constructor with one whose instances implement the
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
* method interface of `delete`, `get`, `has`, and `set`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to have its output memoized.
* @param {Function} [resolver] The function to resolve the cache key.
* @returns {Function} Returns the new memoized function.
* @example
*
* var object = { 'a': 1, 'b': 2 };
* var other = { 'c': 3, 'd': 4 };
*
* var values = _.memoize(_.values);
* values(object);
* // => [1, 2]
*
* values(other);
* // => [3, 4]
*
* object.a = 2;
* values(object);
* // => [1, 2]
*
* // Modify the result cache.
* values.cache.set(object, ['a', 'b']);
* values(object);
* // => ['a', 'b']
*
* // Replace `_.memoize.Cache`.
* _.memoize.Cache = WeakMap;
*/
function memoize(func, resolver) {
if (typeof func != 'function' || resolver && typeof resolver != 'function') {
if (
typeof func != 'function' ||
resolver && typeof resolver != 'function')
{
throw new TypeError(FUNC_ERROR_TEXT);
}
var memoized = function memoized() {
var args = arguments,
key = resolver ? resolver.apply(this, args) : args[0],
cache = memoized.cache;
key = resolver ? resolver.apply(this, args) : args[0],
cache = memoized.cache;

@@ -883,3 +918,2 @@ if (cache.has(key)) {

}
var result = func.apply(this, args);

@@ -889,89 +923,87 @@ memoized.cache = cache.set(key, result);

};
memoized.cache = new (memoize.Cache || MapCache)();
return memoized;
} // Assign cache to `_.memoize`.
}
// Assign cache to `_.memoize`.
memoize.Cache = MapCache;
memoize.Cache = MapCache;
/**
* Performs a
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* comparison between two values to determine if they are equivalent.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.eq(object, object);
* // => true
*
* _.eq(object, other);
* // => false
*
* _.eq('a', 'a');
* // => true
*
* _.eq('a', Object('a'));
* // => false
*
* _.eq(NaN, NaN);
* // => true
*/
* Performs a
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* comparison between two values to determine if they are equivalent.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.eq(object, object);
* // => true
*
* _.eq(object, other);
* // => false
*
* _.eq('a', 'a');
* // => true
*
* _.eq('a', Object('a'));
* // => false
*
* _.eq(NaN, NaN);
* // => true
*/
function eq(value, other) {
return value === other || value !== value && other !== other;
}
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/
var isArray = Array.isArray;
var isArray = Array.isArray;
/**
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
* _.isFunction(/abc/);
* // => false
*/
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
* _.isFunction(/abc/);
* // => false
*/
function isFunction$1(value) {

@@ -983,138 +1015,135 @@ // The use of `Object#toString` avoids issues with the `typeof` operator

}
/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
function isObject(value) {
var type = _typeof(value);
return !!value && (type == 'object' || type == 'function');
}
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return !!value && _typeof(value) == 'object';
}
/**
* Checks if `value` is classified as a `Symbol` primitive or object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
* // => true
*
* _.isSymbol('abc');
* // => false
*/
* Checks if `value` is classified as a `Symbol` primitive or object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
* // => true
*
* _.isSymbol('abc');
* // => false
*/
function isSymbol(value) {
return (
_typeof(value) == 'symbol' ||
isObjectLike(value) && objectToString.call(value) == symbolTag);
}
function isSymbol(value) {
return _typeof(value) == 'symbol' || isObjectLike(value) && objectToString.call(value) == symbolTag;
}
/**
* Converts `value` to a string. An empty string is returned for `null`
* and `undefined` values. The sign of `-0` is preserved.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to process.
* @returns {string} Returns the string.
* @example
*
* _.toString(null);
* // => ''
*
* _.toString(-0);
* // => '-0'
*
* _.toString([1, 2, 3]);
* // => '1,2,3'
*/
* Converts `value` to a string. An empty string is returned for `null`
* and `undefined` values. The sign of `-0` is preserved.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to process.
* @returns {string} Returns the string.
* @example
*
* _.toString(null);
* // => ''
*
* _.toString(-0);
* // => '-0'
*
* _.toString([1, 2, 3]);
* // => '1,2,3'
*/
function toString(value) {
return value == null ? '' : baseToString(value);
}
/**
* Gets the value at `path` of `object`. If the resolved value is
* `undefined`, the `defaultValue` is returned in its place.
*
* @static
* @memberOf _
* @since 3.7.0
* @category Object
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
* @returns {*} Returns the resolved value.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
*
* _.get(object, 'a[0].b.c');
* // => 3
*
* _.get(object, ['a', '0', 'b', 'c']);
* // => 3
*
* _.get(object, 'a.b.c', 'default');
* // => 'default'
*/
* Gets the value at `path` of `object`. If the resolved value is
* `undefined`, the `defaultValue` is returned in its place.
*
* @static
* @memberOf _
* @since 3.7.0
* @category Object
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
* @returns {*} Returns the resolved value.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
*
* _.get(object, 'a[0].b.c');
* // => 3
*
* _.get(object, ['a', '0', 'b', 'c']);
* // => 3
*
* _.get(object, 'a.b.c', 'default');
* // => 'default'
*/
function get(object, path, defaultValue) {

@@ -1127,134 +1156,129 @@ var result = object == null ? undefined : baseGet(object, path);

var createDefaultValidationResult = function createDefaultValidationResult() {
return {
var createDefaultValidationResult = function createDefaultValidationResult() {return {
type: '',
succeeded: true,
message: ''
};
};
var createDefaultInternalValidationResult = function createDefaultInternalValidationResult() {
return {
message: '' };};
var createDefaultInternalValidationResult = function createDefaultInternalValidationResult() {return {
key: '',
type: '',
succeeded: true,
message: ''
};
};
var createDefaultRecordValidationResult = function createDefaultRecordValidationResult() {
return {
message: '' };};
var createDefaultRecordValidationResult = function createDefaultRecordValidationResult() {return {
succeeded: true,
recordErrors: {}
};
};
var createDefaultFormValidationResult = function createDefaultFormValidationResult() {
return {
recordErrors: {} };};
var createDefaultFormValidationResult = function createDefaultFormValidationResult() {return {
succeeded: true,
fieldErrors: {},
recordErrors: {}
};
};
recordErrors: {} };};
var convertFieldValidationToAsyncIfNeeded = function convertFieldValidationToAsyncIfNeeded(validation) {
return function (fieldValidatorArgs) {
var result = validation ? validation(fieldValidatorArgs) : createDefaultValidationResult();
var createDefaultInternalFormValidationResult = function createDefaultInternalFormValidationResult() {return {
succeeded: true,
fieldErrors: {},
recordErrors: {} };};
// Sugar we admit both flavors syncrhonous and asynchronous validators
var convertFieldValidationToAsyncIfNeeded = function convertFieldValidationToAsyncIfNeeded(validation) {return function (fieldValidatorArgs) {
var result = validation ?
validation(fieldValidatorArgs) :
createDefaultValidationResult();
return isPromise(result) ? result : Promise.resolve(result);
};
};
var convertRecordValidationToAsyncIfNeeded = function convertRecordValidationToAsyncIfNeeded(validation) {
return function (recordValidatorArgs) {
var result = validation ? validation(recordValidatorArgs) : createDefaultValidationResult();
};};
var convertRecordValidationToAsyncIfNeeded = function convertRecordValidationToAsyncIfNeeded(validation) {return function (recordValidatorArgs) {
var result = validation ?
validation(recordValidatorArgs) :
createDefaultValidationResult();
return isPromise(result) ? result : Promise.resolve(result);
};
};
};};
var mapToInternalFieldValidation = function mapToInternalFieldValidation(fieldValidation) {
return isFunction(fieldValidation) ? {
var mapToInternalFieldValidation = function mapToInternalFieldValidation(fieldValidation) {return isFunction(fieldValidation) ?
{
validator: convertFieldValidationToAsyncIfNeeded(fieldValidation),
message: void 0,
customArgs: void 0
} : {
validator: convertFieldValidationToAsyncIfNeeded(isFunction(fieldValidation.validator) ? fieldValidation.validator : fieldValidation.validator.validator),
customArgs: void 0 } :
{
validator: convertFieldValidationToAsyncIfNeeded(isFunction(fieldValidation.validator) ?
fieldValidation.validator :
fieldValidation.validator.validator),
customArgs: fieldValidation.customArgs,
message: fieldValidation.message
};
};
message: fieldValidation.message };};
var mapToInternalValidationCollection = function mapToInternalValidationCollection(fieldValidations) {
return Array.isArray(fieldValidations) ? fieldValidations.map(mapToInternalFieldValidation) : [];
};
var buildIntertalSchema = function buildIntertalSchema(internalSchema) {
return internalSchema.reduce(function (internalFieldValidations, _ref) {
var _ref2 = _slicedToArray(_ref, 2),
fieldId = _ref2[0],
fieldValidations = _ref2[1];
var mapToInternalValidationCollection = function mapToInternalValidationCollection(fieldValidations) {return Array.isArray(fieldValidations) ?
fieldValidations.map(mapToInternalFieldValidation) :
[];};
var buildIntertalSchema = function buildIntertalSchema(internalSchema) {return internalSchema.reduce(function (internalFieldValidations, _ref) {var _ref2 = _slicedToArray(_ref, 2),fieldId = _ref2[0],fieldValidations = _ref2[1];
internalFieldValidations[fieldId] = fieldValidations;
return internalFieldValidations;
}, {});
};
}, {});};
var mapToInternalFieldValidationSchema = function mapToInternalFieldValidationSchema(fieldValidationSchema) {
var validationSchema = fieldValidationSchema instanceof Object ? fieldValidationSchema : {};
var internalFieldValidations = Object.entries(validationSchema).map(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 2),
fielId = _ref4[0],
fieldValidations = _ref4[1];
var internalFieldValidations = Object.entries(validationSchema).map(function (_ref3) {var _ref4 = _slicedToArray(_ref3, 2),fielId = _ref4[0],fieldValidations = _ref4[1];return [
fielId,
mapToInternalValidationCollection(fieldValidations)];});
return [fielId, mapToInternalValidationCollection(fieldValidations)];
});
return buildIntertalSchema(internalFieldValidations);
};
var mapToInternalRecordValidation = function mapToInternalRecordValidation(recordValidation) {
return isFunction(recordValidation) ? {
var mapToInternalRecordValidation = function mapToInternalRecordValidation(recordValidation) {return isFunction(recordValidation) ?
{
validator: convertRecordValidationToAsyncIfNeeded(recordValidation),
message: void 0
} : {
validator: convertRecordValidationToAsyncIfNeeded(isFunction(recordValidation.validator) ? recordValidation.validator : recordValidation.validator.validator),
message: recordValidation.message
};
};
message: void 0 } :
var mapToInternalValidationCollection$1 = function mapToInternalValidationCollection(recordValidations) {
return Array.isArray(recordValidations) ? recordValidations.map(mapToInternalRecordValidation) : [];
};
{
validator: convertRecordValidationToAsyncIfNeeded(isFunction(recordValidation.validator) ?
recordValidation.validator :
recordValidation.validator.validator),
message: recordValidation.message };};
var buildIntertalSchema$1 = function buildIntertalSchema(internalSchema) {
return internalSchema.reduce(function (internalRecordValidations, _ref) {
var _ref2 = _slicedToArray(_ref, 2),
recordId = _ref2[0],
recordValidations = _ref2[1];
var mapToInternalValidationCollection$1 = function mapToInternalValidationCollection(recordValidations) {return Array.isArray(recordValidations) ?
recordValidations.map(mapToInternalRecordValidation) :
[];};
var buildIntertalSchema$1 = function buildIntertalSchema(internalSchema) {return internalSchema.reduce(function (internalRecordValidations, _ref) {var _ref2 = _slicedToArray(_ref, 2),recordId = _ref2[0],recordValidations = _ref2[1];
internalRecordValidations[recordId] = recordValidations;
return internalRecordValidations;
}, {});
};
}, {});};
var mapToInternalRecordValidationSchema = function mapToInternalRecordValidationSchema(recordValidationSchema) {
var validationSchema = recordValidationSchema instanceof Object ? recordValidationSchema : {};
var internalRecordValidations = Object.entries(validationSchema).map(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 2),
fielId = _ref4[0],
recordValidations = _ref4[1];
var internalRecordValidations = Object.entries(validationSchema).map(function (_ref3) {var _ref4 = _slicedToArray(_ref3, 2),fielId = _ref4[0],recordValidations = _ref4[1];return [
fielId,
mapToInternalValidationCollection$1(recordValidations)];});
return [fielId, mapToInternalValidationCollection$1(recordValidations)];
});
return buildIntertalSchema$1(internalRecordValidations);
};
var fireAllFieldsValidations = function fireAllFieldsValidations(fieldIds, values, schema, validateField) {
return fieldIds.map(function (fieldId) {
return validateField(fieldId, get_1(values, fieldId, undefined), values, schema);
});
var renameFieldNameKeys = function renameFieldNameKeys(internalValidationResult, fieldKey, fieldErrors, index) {
var fieldNames = Object.keys(fieldErrors);
return fieldNames.reduce(function (result, fieldName) {return Object.assign(Object.assign({}, result), _defineProperty({}, "".concat(fieldKey, "[").concat(index, "].").concat(fieldName), fieldErrors[fieldName]));}, {});
};
var fireAllRecordsValidations = function fireAllRecordsValidations(recordIds, values, schema, validateRecord) {
return recordIds.map(function (recordId) {
return validateRecord(recordId, values, schema);
});
var mapArrayErrorListToValidationResult = function mapArrayErrorListToValidationResult(internalValidationResult, fieldKey) {return internalValidationResult.arrayErrors.reduce(function (validationResult, fieldErrors, index) {return Object.assign(Object.assign({}, validationResult), renameFieldNameKeys(internalValidationResult, fieldKey, fieldErrors, index));}, {});};
var mapInternalValidationResultToValidationResult = function mapInternalValidationResultToValidationResult(internalValidationResult) {return Boolean(internalValidationResult.arrayErrors) ?
mapArrayErrorListToValidationResult(internalValidationResult, internalValidationResult.key) :
{
type: internalValidationResult.type,
message: internalValidationResult.message,
succeeded: internalValidationResult.succeeded };};
var mapInternalFieldErrorsToFieldErrors = function mapInternalFieldErrorsToFieldErrors(internalFieldErrors) {return Object.keys(internalFieldErrors).reduce(function (fieldErrors, field) {
var validationResult = internalFieldErrors[field];
var fieldValidationResult = Boolean(validationResult.arrayErrors) ?
mapArrayErrorListToValidationResult(validationResult, field) : _defineProperty({},
field, validationResult);
return Object.assign(Object.assign({}, fieldErrors), fieldValidationResult);
}, {});};
var mapInternalFormValidationResultToFormValidationResult = function mapInternalFormValidationResultToFormValidationResult(internalFormValidationResult) {
return {
succeeded: internalFormValidationResult.succeeded,
recordErrors: internalFormValidationResult.recordErrors,
fieldErrors: mapInternalFieldErrorsToFieldErrors(internalFormValidationResult.fieldErrors) };
};
var fireAllFieldsValidations = function fireAllFieldsValidations(fieldIds, values, schema, validateField) {return fieldIds.map(function (fieldId) {return validateField(fieldId, get_1(values, fieldId, undefined), values, schema);});};
var fireAllRecordsValidations = function fireAllRecordsValidations(recordIds, values, schema, validateRecord) {return recordIds.map(function (recordId) {return validateRecord(recordId, values, schema);});};
var checkValidationResult = function checkValidationResult(validationResult) {
var result = validationResult;
if (!validationResult || isUndefinedOrNull(validationResult.succeeded)) {

@@ -1265,31 +1289,22 @@ // show a console error, warn the user one of his validators is not well formed

}
return result;
};
var fireValidation = function fireValidation(values, internalRecordValidation) {return internalRecordValidation.
validator({
values: values,
message: internalRecordValidation.message }).
var fireValidation = function fireValidation(values, internalRecordValidation) {
return internalRecordValidation.validator({
values: values,
message: internalRecordValidation.message
}).then(checkValidationResult);
}; // Sequentially resolve promises with reduce: https://css-tricks.com/why-using-reduce-to-sequentially-resolve-promises-works/
then(checkValidationResult);};
// Sequentially resolve promises with reduce: https://css-tricks.com/why-using-reduce-to-sequentially-resolve-promises-works/
// Example run promises until one succeeds: https://gist.github.com/greggman/0b6eafb335de4bbb557c
var iterateValidationsUntilFailOrAllSucceeded = function iterateValidationsUntilFailOrAllSucceeded(values, internalRecordValidations) {return internalRecordValidations.reduce(function (result, next) {return result.then(function (validationResult) {return validationResult.succeeded ?
fireValidation(values, next) :
validationResult;});}, fireValidation(values, internalRecordValidations[0]) // Initial reduce value
);};
var fireSingleRecordValidations = function fireSingleRecordValidations(values, internalRecordValidations) {return arrayContainsEntries(internalRecordValidations) ?
iterateValidationsUntilFailOrAllSucceeded(values, internalRecordValidations) :
Promise.resolve(createDefaultInternalValidationResult());};
var iterateValidationsUntilFailOrAllSucceeded = function iterateValidationsUntilFailOrAllSucceeded(values, internalRecordValidations) {
return internalRecordValidations.reduce(function (result, next) {
return result.then(function (validationResult) {
return validationResult.succeeded ? fireValidation(values, next) : validationResult;
});
}, fireValidation(values, internalRecordValidations[0]) // Initial reduce value
);
};
var fireSingleRecordValidations = function fireSingleRecordValidations(values, internalRecordValidations) {
return arrayContainsEntries(internalRecordValidations) ? iterateValidationsUntilFailOrAllSucceeded(values, internalRecordValidations) : Promise.resolve(createDefaultInternalValidationResult());
};
var checkValidationResult$1 = function checkValidationResult(validationResult) {
var result = validationResult;
if (!validationResult || isUndefinedOrNull(validationResult.succeeded)) {

@@ -1300,49 +1315,30 @@ // show a console error, warn the user one of his validators is not well formed

}
return result;
};
var fireValidation$1 = function fireValidation(value, values, internalFieldValidation) {
return internalFieldValidation.validator({
var fireValidation$1 = function fireValidation(value, values, internalFieldValidation) {return internalFieldValidation.
validator({
value: value,
values: values,
customArgs: internalFieldValidation.customArgs,
message: internalFieldValidation.message
}).then(checkValidationResult$1);
}; // Sequentially resolve promises with reduce: https://css-tricks.com/why-using-reduce-to-sequentially-resolve-promises-works/
message: internalFieldValidation.message }).
then(checkValidationResult$1);};
// Sequentially resolve promises with reduce: https://css-tricks.com/why-using-reduce-to-sequentially-resolve-promises-works/
// Example run promises until one succeeds: https://gist.github.com/greggman/0b6eafb335de4bbb557c
var iterateValidationsUntilFailOrAllSucceeded$1 = function iterateValidationsUntilFailOrAllSucceeded(value, values, internalFieldValidations) {return internalFieldValidations.reduce(function (result, next) {return result.then(function (validationResult) {return validationResult.succeeded ?
fireValidation$1(value, values, next) :
validationResult;});}, fireValidation$1(value, values, internalFieldValidations[0]) // Initial reduce value
);};
var fireSingleFieldValidations = function fireSingleFieldValidations(value, values, internalFieldValidations) {return arrayContainsEntries(internalFieldValidations) ?
iterateValidationsUntilFailOrAllSucceeded$1(value, values, internalFieldValidations) :
Promise.resolve(createDefaultInternalValidationResult());};
var iterateValidationsUntilFailOrAllSucceeded$1 = function iterateValidationsUntilFailOrAllSucceeded(value, values, internalFieldValidations) {
return internalFieldValidations.reduce(function (result, next) {
return result.then(function (validationResult) {
return validationResult.succeeded ? fireValidation$1(value, values, next) : validationResult;
});
}, fireValidation$1(value, values, internalFieldValidations[0]) // Initial reduce value
);
};
var fireSingleFieldValidations = function fireSingleFieldValidations(value, values, internalFieldValidations) {
return arrayContainsEntries(internalFieldValidations) ? iterateValidationsUntilFailOrAllSucceeded$1(value, values, internalFieldValidations) : Promise.resolve(createDefaultInternalValidationResult());
};
var didAllValidationsSucceeded = function didAllValidationsSucceeded(validationResults) {
return validationResults.every(function (fvr) {
return fvr.succeeded;
});
};
var extractErrors = function extractErrors(validationResults) {
return validationResults.reduce(function (errors, _a) {
var key = _a.key,
validationResult = __rest(_a, ["key"]);
var didAllValidationsSucceeded = function didAllValidationsSucceeded(validationResults) {return validationResults.every(function (fvr) {return fvr.succeeded;});};
var extractErrors = function extractErrors(validationResults) {return validationResults.reduce(function (errors, _a) {
var key = _a.key,validationResult = __rest(_a, ["key"]);
errors[key] = Object.assign({}, validationResult);
return errors;
}, {});
};
}, {});};
var buildRecordValidationResult = function buildRecordValidationResult(validationResults) {
var recordValidationResult = createDefaultRecordValidationResult();
if (arrayContainsEntries(validationResults)) {

@@ -1352,8 +1348,6 @@ recordValidationResult.succeeded = didAllValidationsSucceeded(validationResults);

}
return recordValidationResult;
};
var buildFormValidationResult = function buildFormValidationResult(fieldValidationResults, recordValidationResults) {
var formValidationResult = createDefaultFormValidationResult();
var formValidationResult = createDefaultInternalFormValidationResult();
if (arrayContainsEntries(fieldValidationResults)) {

@@ -1363,43 +1357,41 @@ formValidationResult.succeeded = didAllValidationsSucceeded(fieldValidationResults);

}
if (arrayContainsEntries(recordValidationResults)) {
var recordResults = buildRecordValidationResult(recordValidationResults);
formValidationResult.succeeded = formValidationResult.succeeded && recordResults.succeeded;
formValidationResult.succeeded =
formValidationResult.succeeded && recordResults.succeeded;
formValidationResult.recordErrors = recordResults.recordErrors;
}
return formValidationResult;
};
var isIdInSchema = function isIdInSchema(fieldId, schema) {
return !isUndefinedOrNull(schema) && !isUndefinedOrNull(schema[fieldId]);
};
var validateField = function validateField(fieldId, value, values, schema) {
return !isIdInSchema(fieldId, schema) ? Promise.resolve(createDefaultInternalValidationResult()) : fireSingleFieldValidations(value, values, schema[fieldId]).then(function (validationResult) {
var isIdInSchema = function isIdInSchema(fieldId, schema) {return !isUndefinedOrNull(schema) && !isUndefinedOrNull(schema[fieldId]);};
var validateField = function validateField(fieldId, value, values, schema) {return !isIdInSchema(fieldId, schema) ?
Promise.resolve(createDefaultInternalValidationResult()) :
fireSingleFieldValidations(value, values, schema[fieldId]).
then(function (validationResult) {
validationResult.key = fieldId;
return validationResult;
})["catch"](function (error) {
})["catch"](
function (error) {
var message = "Validation Exception, field: ".concat(fieldId);
console.error(message);
throw error;
});
};
var validateSingleRecord = function validateSingleRecord(recordId, values, schema) {
return !isIdInSchema(recordId, schema) ? Promise.resolve(createDefaultInternalValidationResult()) : fireSingleRecordValidations(values, schema[recordId]).then(function (validationResult) {
});};
var validateSingleRecord = function validateSingleRecord(recordId, values, schema) {return !isIdInSchema(recordId, schema) ?
Promise.resolve(createDefaultInternalValidationResult()) :
fireSingleRecordValidations(values, schema[recordId]).
then(function (validationResult) {
validationResult.key = recordId;
return validationResult;
})["catch"](function (error) {
})["catch"](
function (error) {
var message = "Validation Exception, record: ".concat(recordId);
console.error(message);
throw error;
});
};
});};
var validateRecord = function validateRecord(values, schema) {
var promiseValidationResults = fireAllRecordsValidations(safeObjectKeys(schema), values, schema, validateSingleRecord);
return Promise.all(promiseValidationResults).then(function (validationResults) {
return buildRecordValidationResult(validationResults);
})["catch"](function (error) {
return Promise.all(promiseValidationResults).
then(function (validationResults) {return buildRecordValidationResult(validationResults);})["catch"](
function (error) {
var message = 'Uncontrolled error validating records';

@@ -1413,13 +1405,9 @@ console.error(message);

var promiseRecordValidationResults = fireAllRecordsValidations(safeObjectKeys(recordSchema), values, recordSchema, validateSingleRecord);
return Promise.all(promiseFieldValidationResults).then(function (fieldValidationResults) {
return Promise.all(promiseRecordValidationResults).then(function (recordValidationResults) {
return [fieldValidationResults, recordValidationResults];
});
}).then(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
fieldValidationResults = _ref2[0],
recordValidationResults = _ref2[1];
return Promise.all(promiseFieldValidationResults).
then(function (fieldValidationResults) {return Promise.all(promiseRecordValidationResults).then(function (recordValidationResults) {return [
fieldValidationResults,
recordValidationResults];});}).
return buildFormValidationResult(fieldValidationResults, recordValidationResults);
})["catch"](function (error) {
then(function (_ref) {var _ref2 = _slicedToArray(_ref, 2),fieldValidationResults = _ref2[0],recordValidationResults = _ref2[1];return buildFormValidationResult(fieldValidationResults, recordValidationResults);})["catch"](
function (error) {
var message = 'Uncontrolled error validating records';

@@ -1431,69 +1419,39 @@ console.error(message);

var FormValidation = function FormValidation(validationSchema) {
var _this = this;
_classCallCheck(this, FormValidation);
var FormValidation =
function FormValidation(validationSchema) {var _this = this;_classCallCheck(this, FormValidation);
this.fieldSchema = {};
this.recordSchema = {};
this.setupValidationSchema = function (validationSchema) {
if (validationSchema && _typeof(validationSchema) === 'object') {
var record = validationSchema.record,
field = validationSchema.field;
if (validationSchema && _typeof(validationSchema) === 'object') {var
record = validationSchema.record,field = validationSchema.field;
if (field && _typeof(field) === 'object') {
_this.fieldSchema = mapToInternalFieldValidationSchema(validationSchema.field);
}
if (record && _typeof(record) === 'object') {
_this.recordSchema = mapToInternalRecordValidationSchema(validationSchema.record);
}
} else {
} else
{
console.error('ValidationSchema must be a valid object');
}
};
this.validateField = function (fieldId, value, values) {
return validateField(fieldId, value, values, _this.fieldSchema).then(function (_a) {
var key = _a.key,
validationResult = __rest(_a, ["key"]);
return Object.assign({}, validationResult);
});
};
this.validateRecord = function (values) {
return validateRecord(values, _this.recordSchema);
};
this.validateForm = function (values) {
return validateForm(values, _this.fieldSchema, _this.recordSchema);
};
this.validateField = function (fieldId, value, values) {return validateField(fieldId, value, values, _this.fieldSchema).then(mapInternalValidationResultToValidationResult);};
this.validateRecord = function (values) {return validateRecord(values, _this.recordSchema);};
this.validateForm = function (values) {return validateForm(values, _this.fieldSchema, _this.recordSchema).then(mapInternalFormValidationResultToFormValidationResult);};
this.updateValidationSchema = function (validationSchema) {
_this.setupValidationSchema(validationSchema);
};
this.setupValidationSchema(validationSchema);
};
var createFormValidation = function createFormValidation(validationSchema) {
return new FormValidation(validationSchema);
};
var getArgsToParse = function getArgsToParse(message) {
return message.match(/{{[^{}][\w\.]*}}/g);
};
var createFormValidation = function createFormValidation(validationSchema) {return new FormValidation(validationSchema);};
var getArgPath = function getArgPath(arg) {
return arg.replace(/[{}]/g, '');
};
var getArgsToParse = function getArgsToParse(message) {return message.match(/{{[^{}][\w\.]*}}/g);};
var getArgPath = function getArgPath(arg) {return arg.replace(/[{}]/g, '');};
var parseMessage = function parseMessage(message, customArgs) {
var parsableArgs = getArgsToParse(message);
return Array.isArray(parsableArgs) ? parsableArgs.reduce(function (customMessage, arg) {
return customMessage.replace(arg, get_1(customArgs, getArgPath(arg), arg));
}, message) : message;
return Array.isArray(parsableArgs) ?
parsableArgs.reduce(function (customMessage, arg) {return customMessage.replace(arg, get_1(customArgs, getArgPath(arg), arg));}, message) :
message;
};
var parseMessageWithCustomArgs = function parseMessageWithCustomArgs(message, customArgs) {

@@ -1505,33 +1463,19 @@ return message ? parseMessage(message, customArgs) : '';

var defaultMessage = 'Please fill in this mandatory field.';
var setErrorMessage = function setErrorMessage(message) {
return defaultMessage = message;
};
var DEFAULT_PARAMS = {
trim: true
};
var isStringValid = function isStringValid(value, trim) {
return trim ? value.trim().length > 0 : value.length > 0;
};
var isNonStringValid = function isNonStringValid(value) {
return value !== void 0 && value !== null;
};
var isValidField = function isValidField(value, trim) {
return typeof value === 'string' ? isStringValid(value, trim) : isNonStringValid(value);
};
var validator = function validator(fieldValidatorArgs) {
var value = fieldValidatorArgs.value,
_fieldValidatorArgs$c = fieldValidatorArgs.customArgs,
customArgs = _fieldValidatorArgs$c === void 0 ? DEFAULT_PARAMS : _fieldValidatorArgs$c,
_fieldValidatorArgs$m = fieldValidatorArgs.message,
message = _fieldValidatorArgs$m === void 0 ? defaultMessage : _fieldValidatorArgs$m;
var setErrorMessage = function setErrorMessage(message) {return defaultMessage = message;};
var DEFAULT_PARAMS = { trim: true };
var isStringValid = function isStringValid(value, trim) {return trim ? value.trim().length > 0 : value.length > 0;};
var isNonStringValid = function isNonStringValid(value) {return value !== void 0 && value !== null;};
var isValidField = function isValidField(value, trim) {return typeof value === 'string' ?
isStringValid(value, trim) :
isNonStringValid(value);};
var validator = function validator(fieldValidatorArgs) {var
value = fieldValidatorArgs.value,_fieldValidatorArgs$c = fieldValidatorArgs.customArgs,customArgs = _fieldValidatorArgs$c === void 0 ? DEFAULT_PARAMS : _fieldValidatorArgs$c,_fieldValidatorArgs$m = fieldValidatorArgs.message,message = _fieldValidatorArgs$m === void 0 ? defaultMessage : _fieldValidatorArgs$m;
var succeeded = isValidField(value, Boolean(customArgs.trim));
return {
succeeded: succeeded,
message: succeeded ? '' : parseMessageWithCustomArgs(message, customArgs),
type: VALIDATOR_TYPE
};
message: succeeded ?
'' :
parseMessageWithCustomArgs(message, customArgs),
type: VALIDATOR_TYPE };
};

@@ -1545,26 +1489,13 @@

var isEmptyValue = function isEmptyValue(value) {
return value === null || value === undefined || value === '';
};
var isEmptyValue = function isEmptyValue(value) {return value === null || value === undefined || value === '';};
var isValidPattern = function isValidPattern(value, pattern) {return isEmptyValue(value) ? true : pattern.test(value);};
var isValidPattern = function isValidPattern(value, pattern) {
return isEmptyValue(value) ? true : pattern.test(value);
};
var VALIDATOR_TYPE$1 = 'EMAIL';
var defaultMessage$1 = 'Please enter a valid email address.';
var setErrorMessage$1 = function setErrorMessage(message) {
return defaultMessage$1 = message;
}; // RegExp from http://emailregex.com
var setErrorMessage$1 = function setErrorMessage(message) {return defaultMessage$1 = message;};
// RegExp from http://emailregex.com
var EMAIL_PATTERN = /^(([^<>()\[\]\\.,;:\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,}))$/;
var isValidField$1 = function isValidField(value) {
return isValidPattern(value, EMAIL_PATTERN);
};
var validator$1 = function validator(fieldValidatorArgs) {
var value = fieldValidatorArgs.value,
_fieldValidatorArgs$m = fieldValidatorArgs.message,
message = _fieldValidatorArgs$m === void 0 ? defaultMessage$1 : _fieldValidatorArgs$m;
var isValidField$1 = function isValidField(value) {return isValidPattern(value, EMAIL_PATTERN);};
var validator$1 = function validator(fieldValidatorArgs) {var
value = fieldValidatorArgs.value,_fieldValidatorArgs$m = fieldValidatorArgs.message,message = _fieldValidatorArgs$m === void 0 ? defaultMessage$1 : _fieldValidatorArgs$m;
var succeeded = isValidField$1(value);

@@ -1574,4 +1505,4 @@ return {

message: succeeded ? '' : message,
type: VALIDATOR_TYPE$1
};
type: VALIDATOR_TYPE$1 };
};

@@ -1587,15 +1518,9 @@

var defaultMessage$2 = 'Please provide a valid format.';
var setErrorMessage$2 = function setErrorMessage(message) {
return defaultMessage$2 = message;
};
var setErrorMessage$2 = function setErrorMessage(message) {return defaultMessage$2 = message;};
var BAD_PARAMETER = 'FieldValidationError: pattern option for pattern validation is mandatory. Example: { pattern: /d+/ }.';
var DEFAULT_PARAMS$1 = null;
function getRegExp(pattern) {
return pattern instanceof RegExp ? pattern : new RegExp(pattern);
}
function parsePattern(_ref) {
var pattern = _ref.pattern;
function parsePattern(_ref) {var pattern = _ref.pattern;
// Avoid RegExp like /true/ /false/ and /null/ without an explicit "true", "false" or "null"

@@ -1605,16 +1530,9 @@ if (typeof pattern === 'boolean' || pattern === null) {

}
return getRegExp(pattern);
}
var validator$2 = function validator(fieldValidatorArgs) {
if (!fieldValidatorArgs.customArgs) {
throw new Error(BAD_PARAMETER);
}
var value = fieldValidatorArgs.value,
_fieldValidatorArgs$c = fieldValidatorArgs.customArgs,
customArgs = _fieldValidatorArgs$c === void 0 ? DEFAULT_PARAMS$1 : _fieldValidatorArgs$c,
_fieldValidatorArgs$m = fieldValidatorArgs.message,
message = _fieldValidatorArgs$m === void 0 ? defaultMessage$2 : _fieldValidatorArgs$m;
}var
value = fieldValidatorArgs.value,_fieldValidatorArgs$c = fieldValidatorArgs.customArgs,customArgs = _fieldValidatorArgs$c === void 0 ? DEFAULT_PARAMS$1 : _fieldValidatorArgs$c,_fieldValidatorArgs$m = fieldValidatorArgs.message,message = _fieldValidatorArgs$m === void 0 ? defaultMessage$2 : _fieldValidatorArgs$m;
var pattern = parsePattern(customArgs);

@@ -1624,5 +1542,7 @@ var succeeded = isValidPattern(value, pattern);

succeeded: succeeded,
message: succeeded ? '' : parseMessageWithCustomArgs(message, customArgs),
type: VALIDATOR_TYPE$2
};
message: succeeded ?
'' :
parseMessageWithCustomArgs(message, customArgs),
type: VALIDATOR_TYPE$2 };
};

@@ -1638,7 +1558,5 @@

var length = customParams.length === null ? NaN : Number(customParams.length);
if (isNaN(length)) {
throw new Error(errorMessage);
}
return length;

@@ -1653,22 +1571,11 @@ }

var defaultMessage$3 = 'The value provided does not fulfill min length';
var setErrorMessage$3 = function setErrorMessage(message) {
return defaultMessage$3 = message;
};
var setErrorMessage$3 = function setErrorMessage(message) {return defaultMessage$3 = message;};
var BAD_PARAMETER$1 = 'FieldValidationError: Parameter "length" for minLength in customArgs is mandatory and should be a valid number. Example: { length: 4 }.';
var DEFAULT_PARAMS$2 = null;
var isStringLengthValid = function isStringLengthValid(value, length) {
return value.length >= length;
};
var isStringLengthValid = function isStringLengthValid(value, length) {return value.length >= length;};
var validator$3 = function validator(fieldValidatorArgs) {
if (!fieldValidatorArgs.customArgs) {
throw new Error(BAD_PARAMETER$1);
}
var value = fieldValidatorArgs.value,
_fieldValidatorArgs$c = fieldValidatorArgs.customArgs,
customArgs = _fieldValidatorArgs$c === void 0 ? DEFAULT_PARAMS$2 : _fieldValidatorArgs$c,
_fieldValidatorArgs$m = fieldValidatorArgs.message,
message = _fieldValidatorArgs$m === void 0 ? defaultMessage$3 : _fieldValidatorArgs$m;
}var
value = fieldValidatorArgs.value,_fieldValidatorArgs$c = fieldValidatorArgs.customArgs,customArgs = _fieldValidatorArgs$c === void 0 ? DEFAULT_PARAMS$2 : _fieldValidatorArgs$c,_fieldValidatorArgs$m = fieldValidatorArgs.message,message = _fieldValidatorArgs$m === void 0 ? defaultMessage$3 : _fieldValidatorArgs$m;
var length = parseLengthParams(customArgs, BAD_PARAMETER$1);

@@ -1678,5 +1585,7 @@ var succeeded = isLengthValid(value, length, isStringLengthValid);

succeeded: succeeded,
message: succeeded ? '' : parseMessageWithCustomArgs(message, customArgs),
type: VALIDATOR_TYPE$3
};
message: succeeded ?
'' :
parseMessageWithCustomArgs(message, customArgs),
type: VALIDATOR_TYPE$3 };
};

@@ -1692,22 +1601,11 @@

var defaultMessage$4 = 'The value provided does not fulfill max length';
var setErrorMessage$4 = function setErrorMessage(message) {
return defaultMessage$4 = message;
};
var setErrorMessage$4 = function setErrorMessage(message) {return defaultMessage$4 = message;};
var BAD_PARAMETER$2 = 'FieldValidationError: Parameter "length" for maxLength in customArgs is mandatory and should be a valid number. Example: { length: 4 }.';
var DEFAULT_PARAMS$3 = null;
var isStringLengthValid$1 = function isStringLengthValid(value, length) {
return value.length <= length;
};
var isStringLengthValid$1 = function isStringLengthValid(value, length) {return value.length <= length;};
var validator$4 = function validator(fieldValidatorArgs) {
if (!fieldValidatorArgs.customArgs) {
throw new Error(BAD_PARAMETER$2);
}
var value = fieldValidatorArgs.value,
_fieldValidatorArgs$c = fieldValidatorArgs.customArgs,
customArgs = _fieldValidatorArgs$c === void 0 ? DEFAULT_PARAMS$3 : _fieldValidatorArgs$c,
_fieldValidatorArgs$m = fieldValidatorArgs.message,
message = _fieldValidatorArgs$m === void 0 ? defaultMessage$4 : _fieldValidatorArgs$m;
}var
value = fieldValidatorArgs.value,_fieldValidatorArgs$c = fieldValidatorArgs.customArgs,customArgs = _fieldValidatorArgs$c === void 0 ? DEFAULT_PARAMS$3 : _fieldValidatorArgs$c,_fieldValidatorArgs$m = fieldValidatorArgs.message,message = _fieldValidatorArgs$m === void 0 ? defaultMessage$4 : _fieldValidatorArgs$m;
var length = parseLengthParams(customArgs, BAD_PARAMETER$2);

@@ -1717,5 +1615,7 @@ var succeeded = isLengthValid(value, length, isStringLengthValid$1);

succeeded: succeeded,
message: succeeded ? '' : parseMessageWithCustomArgs(message, customArgs),
type: VALIDATOR_TYPE$4
};
message: succeeded ?
'' :
parseMessageWithCustomArgs(message, customArgs),
type: VALIDATOR_TYPE$4 };
};

@@ -1729,10 +1629,29 @@

var index = {
required: required,
email: email,
pattern: pattern,
minLength: minLength,
maxLength: maxLength
};
var createEmptyArrayValidationResult = function createEmptyArrayValidationResult() {return {
succeeded: true,
arrayErrors: [] };};
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);}));},
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);}));};
var array = /*#__PURE__*/Object.freeze({
__proto__: null,
validator: validator$5
});
var index = { required: required, email: email, pattern: pattern, minLength: minLength, maxLength: maxLength, array: array };
export { FormValidation, index as Validators, createDefaultFormValidationResult, createDefaultRecordValidationResult, createDefaultValidationResult, createFormValidation, parseMessageWithCustomArgs };

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

!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){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var t=[],n=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(n=(u=a.next()).done)&&(t.push(u.value),!r||t.length!==r);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==a.return||a.return()}finally{if(o)throw i}}return t}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}
!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.")}
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Copyright (c) Microsoft Corporation.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */()}function n(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}var o=function(e){return function(e){return Array.isArray(e)?e.length:0}(e)>0},i=function(e){return"function"==typeof e},u=function(e){return null==e},a=function(e){return e instanceof Promise},c=function(e){return Boolean(e)?Object.keys(e):[]},s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},l="Expected a function",f="__lodash_hash_undefined__",d=1/0,p="[object Function]",v="[object GeneratorFunction]",h="[object Symbol]",m=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,y=/^\w*$/,g=/^\./,_=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,b=/\\(\\)?/g,E=/^\[object .+?Constructor\]$/,j="object"==r(s)&&s&&s.Object===Object&&s,w="object"==("undefined"==typeof self?"undefined":r(self))&&self&&self.Object===Object&&self,O=j||w||Function("return this")();var A,S=Array.prototype,P=Function.prototype,x=Object.prototype,k=O["__core-js_shared__"],V=(A=/[^.]+$/.exec(k&&k.keys&&k.keys.IE_PROTO||""))?"Symbol(src)_1."+A:"",F=P.toString,R=x.hasOwnProperty,T=x.toString,M=RegExp("^"+F.call(R).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),$=O.Symbol,N=S.splice,z=Q(O,"Map"),L=Q(Object,"create"),I=$?$.prototype:void 0,C=I?I.toString:void 0;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 G(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){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,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 H(e,t){for(var n,o=0,i=(t=function(e,t){if(K(e))return!1;var n=r(e);if("number"==n||"symbol"==n||"boolean"==n||null==e||ee(e))return!0;return y.test(e)||!m.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:K(n=t)?n:W(n)).length;null!=e&&o<i;)e=e[X(t[o++])];return o&&o==i?e:void 0}function Z(e){return!(!Y(e)||(r=e,V&&V in r))&&(function(e){var r=Y(e)?T.call(e):"";return r==p||r==v}(e)||function(e){var r=!1;if(null!=e&&"function"!=typeof e.toString)try{r=!!(e+"")}catch(e){}return r}(e)?M:E).test(function(e){if(null!=e){try{return F.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var r}function q(e,t){var n,o,i=e.__data__;return("string"==(o=r(n=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function Q(e,r){var t=function(e,r){return null==e?void 0:e[r]}(e,r);return Z(t)?t:void 0}D.prototype.clear=function(){this.__data__=L?L(null):{}},D.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},D.prototype.get=function(e){var r=this.__data__;if(L){var t=r[e];return t===f?void 0:t}return R.call(r,e)?r[e]:void 0},D.prototype.has=function(e){var r=this.__data__;return L?void 0!==r[e]:R.call(r,e)},D.prototype.set=function(e,r){return this.__data__[e]=L&&void 0===r?f:r,this},G.prototype.clear=function(){this.__data__=[]},G.prototype.delete=function(e){var r=this.__data__,t=B(r,e);return!(t<0)&&(t==r.length-1?r.pop():N.call(r,t,1),!0)},G.prototype.get=function(e){var r=this.__data__,t=B(r,e);return t<0?void 0:r[t][1]},G.prototype.has=function(e){return B(this.__data__,e)>-1},G.prototype.set=function(e,r){var t=this.__data__,n=B(t,e);return n<0?t.push([e,r]):t[n][1]=r,this},U.prototype.clear=function(){this.__data__={hash:new D,map:new(z||G),string:new D}},U.prototype.delete=function(e){return q(this,e).delete(e)},U.prototype.get=function(e){return q(this,e).get(e)},U.prototype.has=function(e){return q(this,e).has(e)},U.prototype.set=function(e,r){return q(this,e).set(e,r),this};var W=J((function(e){var r;e=null==(r=e)?"":function(e){if("string"==typeof e)return e;if(ee(e))return C?C.call(e):"";var r=e+"";return"0"==r&&1/e==-d?"-0":r}(r);var t=[];return g.test(e)&&t.push(""),e.replace(_,(function(e,r,n,o){t.push(n?o.replace(b,"$1"):r||e)})),t}));function X(e){if("string"==typeof e||ee(e))return e;var r=e+"";return"0"==r&&1/e==-d?"-0":r}function J(e,r){if("function"!=typeof e||r&&"function"!=typeof r)throw new TypeError(l);var t=function t(){var n=arguments,o=r?r.apply(this,n):n[0],i=t.cache;if(i.has(o))return i.get(o);var u=e.apply(this,n);return t.cache=i.set(o,u),u};return t.cache=new(J.Cache||U),t}J.Cache=U;var K=Array.isArray;function Y(e){var t=r(e);return!!e&&("object"==t||"function"==t)}function ee(e){return"symbol"==r(e)||function(e){return!!e&&"object"==r(e)}(e)&&T.call(e)==h}var re=function(e,r,t){var n=null==e?void 0:H(e,r);return void 0===n?t:n},te=function(){return{type:"",succeeded:!0,message:""}},ne=function(){return{succeeded:!0,recordErrors:{}}},oe=function(){return{succeeded:!0,fieldErrors:{},recordErrors:{}}},ie=function(e){return function(r){var t=e?e(r):{type:"",succeeded:!0,message:""};return a(t)?t:Promise.resolve(t)}},ue=function(e){return function(r){var t=e?e(r):{type:"",succeeded:!0,message:""};return a(t)?t:Promise.resolve(t)}},ae=function(e){return i(e)?{validator:ie(e),message:void 0,customArgs:void 0}:{validator:ie(i(e.validator)?e.validator:e.validator.validator),customArgs:e.customArgs,message:e.message}},ce=function(e){return Array.isArray(e)?e.map(ae):[]},se=function(e){var r=e instanceof Object?e:{},n=Object.entries(r).map((function(e){var r=t(e,2),n=r[0],o=r[1];return[n,ce(o)]}));return n.reduce((function(e,r){var n=t(r,2),o=n[0],i=n[1];return e[o]=i,e}),{})},le=function(e){return i(e)?{validator:ue(e),message:void 0}:{validator:ue(i(e.validator)?e.validator:e.validator.validator),message:e.message}},fe=function(e){return Array.isArray(e)?e.map(le):[]},de=function(e){var r=e instanceof Object?e:{},n=Object.entries(r).map((function(e){var r=t(e,2),n=r[0],o=r[1];return[n,fe(o)]}));return n.reduce((function(e,r){var n=t(r,2),o=n[0],i=n[1];return e[o]=i,e}),{})},pe=function(e,r,t,n){return e.map((function(e){return n(e,r,t)}))},ve=function(e){var r=e;return e&&!u(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(ve)},me=function(e,r){return o(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:""})},ye=function(e){var r=e;return e&&!u(e.succeeded)||(console.error("form-validators: One of the field validator is returning a non expected value."),r={key:"",type:"",succeeded:!0,message:""}),r},ge=function(e,r,t){return t.validator({value:e,values:r,customArgs:t.customArgs,message:t.message}).then(ye)},_e=function(e,r,t){return o(t)?function(e,r,t){return t.reduce((function(t,n){return t.then((function(t){return t.succeeded?ge(e,r,n):t}))}),ge(e,r,t[0]))}(e,r,t):Promise.resolve({key:"",type:"",succeeded:!0,message:""})},be=function(e){return e.every((function(e){return e.succeeded}))},Ee=function(e){return e.reduce((function(e,r){var t=r.key,o=n(r,["key"]);return e[t]=Object.assign({},o),e}),{})},je=function(e){var r={succeeded:!0,recordErrors:{}};return o(e)&&(r.succeeded=be(e),r.recordErrors=Ee(e)),r},we=function(e,r){return!u(r)&&!u(r[e])},Oe=function(e,r,t,n){return we(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:""})},Ae=function(e,r,t){return we(e,t)?me(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:""})},Se=function(e,r,n){var i=function(e,r,t,n){return e.map((function(e){return n(e,re(r,e,void 0),r,t)}))}(c(r),e,r,Oe),u=pe(c(n),e,n,Ae);return Promise.all(i).then((function(e){return Promise.all(u).then((function(r){return[e,r]}))})).then((function(e){var r=t(e,2);return function(e,r){var t={succeeded:!0,fieldErrors:{},recordErrors:{}};if(o(e)&&(t.succeeded=be(e),t.fieldErrors=Ee(e)),o(r)){var n=je(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 o=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,n=e.field;n&&"object"===r(n)&&(o.fieldSchema=se(e.field)),t&&"object"===r(t)&&(o.recordSchema=de(e.record))}else console.error("ValidationSchema must be a valid object")},this.validateField=function(e,r,t){return Oe(e,r,t,o.fieldSchema).then((function(e){e.key;var r=n(e,["key"]);return Object.assign({},r)}))},this.validateRecord=function(e){return function(e,r){var t=pe(c(r),e,r,Ae);return Promise.all(t).then((function(e){return je(e)})).catch((function(e){throw console.error("Uncontrolled error validating records"),e}))}(e,o.recordSchema)},this.validateForm=function(e){return Se(e,o.fieldSchema,o.recordSchema)},this.updateValidationSchema=function(e){o.setupValidationSchema(e)},this.setupValidationSchema(t)},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,re(r,function(e){return e.replace(/[{}]/g,"")}(t),t))}),e):e}(e,r):""},ke="Please fill in this mandatory field.",Ve={trim:!0},Fe=function(e,r){return!!function(e){return null==e||""===e}(e)||r.test(e)},Re="Please enter a valid email address.",Te=/^(([^<>()\[\]\\.,;:\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,}))$/,Me="Please provide a valid format.",$e="FieldValidationError: pattern option for pattern validation is mandatory. Example: { pattern: /d+/ }.";function Ne(e){var r=e.pattern;if("boolean"==typeof r||null===r)throw new Error($e);return function(e){return e instanceof RegExp?e:new RegExp(e)}(r)}function ze(e,r){var t=null===e.length?NaN:Number(e.length);if(isNaN(t))throw new Error(r);return t}function Le(e,r,t){return"string"!=typeof e||t(e,r)}var Ie="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},Ge="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 }.',Be=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,i=void 0===o?ke:o,u=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:u,message:u?"":xe(i,n),type:"REQUIRED"}}}),email:Object.freeze({__proto__:null,setErrorMessage:function(e){return Re=e},validator:function(e){var r=e.value,t=e.message,n=void 0===t?Re:t,o=function(e){return Fe(e,Te)}(r);return{succeeded:o,message:o?"":n,type:"EMAIL"}}}),pattern:Object.freeze({__proto__:null,setErrorMessage:function(e){return Me=e},validator:function(e){if(!e.customArgs)throw new Error($e);var r=e.value,t=e.customArgs,n=void 0===t?null:t,o=e.message,i=void 0===o?Me:o,u=Ne(n),a=Fe(r,u);return{succeeded:a,message:a?"":xe(i,n),type:"PATTERN"}}}),minLength:Object.freeze({__proto__:null,setErrorMessage:function(e){return Ie=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,i=void 0===o?Ie:o,u=Le(r,ze(n,Ce),De);return{succeeded:u,message:u?"":xe(i,n),type:"MIN_LENGTH"}}}),maxLength:Object.freeze({__proto__:null,setErrorMessage:function(e){return Ge=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,i=void 0===o?Ge:o,u=Le(r,ze(n,Ue),Be);return{succeeded:u,message:u?"":xe(i,n),type:"MAX_LENGTH"}}})};e.FormValidation=Pe,e.Validators=He,e.createDefaultFormValidationResult=oe,e.createDefaultRecordValidationResult=ne,e.createDefaultValidationResult=te,e.createFormValidation=function(e){return new Pe(e)},e.parseMessageWithCustomArgs=xe,Object.defineProperty(e,"__esModule",{value:!0})}));
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 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})}));
{
"name": "@lemoncode/fonk",
"version": "1.3.0",
"version": "1.4.0-beta.1",
"description": "Form schema validator library",

@@ -27,3 +27,3 @@ "main": "dist/@lemoncode/fonk.cjs.js",

"path": "./dist/**/*.js",
"maxSize": "11.5kB"
"maxSize": "13.5kB"
}

@@ -30,0 +30,0 @@ ],

@@ -43,3 +43,3 @@ import {

values?: any
) => Promise<ValidationResult>;
) => Promise<ValidationResult | { [fieldId: string]: ValidationResult }>;
validateRecord: (values: any) => Promise<RecordValidationResult>;

@@ -78,2 +78,3 @@ validateForm: (values: any) => Promise<FormValidationResult>;

export const maxLength: FieldValidator;
export const array: FieldValidator;
}

@@ -80,0 +81,0 @@

@@ -43,11 +43,1 @@ import { ValidationResult } from './result.model';

}
interface InternalFieldValidation {
validator: FieldValidationFunctionAsync;
customArgs?: any;
message?: string | string[];
}
export interface InternalFieldValidationSchema {
[fieldId: string]: InternalFieldValidation[];
}

@@ -40,10 +40,1 @@ import { ValidationResult } from './result.model';

}
interface InternalRecordValidation {
validator: RecordValidationFunctionAsync;
message?: string | string[];
}
export type InternalRecordValidationSchema = {
[recordId: string]: InternalRecordValidation[];
};

@@ -34,8 +34,1 @@ export interface ValidationResult {

});
export interface InternalValidationResult {
key: string;
type: string;
succeeded: boolean;
message: string;
}

Sorry, the diff of this file is too big to display

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