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 0.4.1 to 0.4.2

531

dist/@lemoncode/fonk.cjs.js

@@ -131,120 +131,2 @@ 'use strict';

var createDefaultValidationResult = function createDefaultValidationResult() {
return {
type: '',
succeeded: true,
message: ''
};
};
var createDefaultInternalValidationResult = function createDefaultInternalValidationResult() {
return {
key: '',
type: '',
succeeded: true,
message: ''
};
};
var createDefaultRecordValidationResult = function createDefaultRecordValidationResult() {
return {
succeeded: true,
recordErrors: {}
};
};
var createDefaultFormValidationResult = function createDefaultFormValidationResult() {
return {
succeeded: true,
fieldErrors: {},
recordErrors: {}
};
};
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();
return isPromise(result) ? result : Promise.resolve(result);
};
};
var mapToInternalFieldValidation = function mapToInternalFieldValidation(fieldValidation) {
return isFunction(fieldValidation) ? {
validator: convertFieldValidationToAsyncIfNeeded(fieldValidation),
message: void 0,
customArgs: void 0
} : {
validator: convertFieldValidationToAsyncIfNeeded(fieldValidation.validator),
customArgs: fieldValidation.customArgs,
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];
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];
return [fielId, mapToInternalValidationCollection(fieldValidations)];
});
return buildIntertalSchema(internalFieldValidations);
};
var mapToInternalRecordValidation = function mapToInternalRecordValidation(recordValidation) {
return isFunction(recordValidation) ? {
validator: convertRecordValidationToAsyncIfNeeded(recordValidation),
message: void 0
} : {
validator: convertRecordValidationToAsyncIfNeeded(recordValidation.validator),
message: recordValidation.message
};
};
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];
return [fielId, mapToInternalValidationCollection$1(recordValidations)];
});
return buildIntertalSchema$1(internalRecordValidations);
};
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

@@ -262,16 +144,17 @@

/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to stand-in for `undefined` hash values. */
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/** Used as references for various `Number` constants. */
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
/** `Object#toString` result references. */
/** `Object#toString` result references. */
var funcTag = '[object Function]',
genTag = '[object GeneratorFunction]',
symbolTag = '[object Symbol]';
/** Used to match property names within property paths. */
/** Used to match property names within property paths. */
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,

@@ -281,3 +164,2 @@ reIsPlainProp = /^\w*$/,

rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
/**

@@ -287,19 +169,19 @@ * Used to match `RegExp`

*/
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
/** Used to match backslashes in property paths. */
/** Used to match backslashes in property paths. */
var reEscapeChar = /\\(\\)?/g;
/** Used to detect host constructors (Safari). */
/** Used to detect host constructors (Safari). */
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 == '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')();
/**

@@ -313,6 +195,6 @@ * Gets the value at `key` of `object`.

*/
function getValue(object, key) {
return object == null ? undefined : object[key];
}
/**

@@ -325,2 +207,4 @@ * Checks if `value` is a host object in IE < 9.

*/
function isHostObject(value) {

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

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

@@ -336,25 +221,27 @@ try {

}
return result;
}
/** Used for built-in method references. */
/** Used for built-in method references. */
var arrayProto = Array.prototype,
funcProto = Function.prototype,
objectProto = Object.prototype;
/** Used to detect overreaching core-js shims. */
/** Used to detect overreaching core-js shims. */
var coreJsData = root['__core-js_shared__'];
/** Used to detect methods masquerading as native. */
/** Used to detect methods masquerading as native. */
var maskSrcKey = (function() {
var maskSrcKey = function () {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
return uid ? ('Symbol(src)_1.' + uid) : '';
}());
return uid ? 'Symbol(src)_1.' + uid : '';
}();
/** Used to resolve the decompiled source of functions. */
/** Used to resolve the decompiled source of functions. */
var funcToString = funcProto.toString;
/** Used to check objects for own properties. */
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**

@@ -365,22 +252,19 @@ * Used to resolve the

*/
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$1 = root.Symbol,
var _Symbol = root.Symbol,
splice = arrayProto.splice;
/* Built-in method references that are verified to be native. */
/* Built-in method references that are verified to be native. */
var Map = getNative(root, 'Map'),
nativeCreate = getNative(Object, 'create');
/** Used to convert symbols to primitives and strings. */
/** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
symbolToString = symbolProto ? symbolProto.toString : undefined;
/**

@@ -393,7 +277,8 @@ * Creates a hash object.

*/
function Hash(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
this.clear();
while (++index < length) {

@@ -404,3 +289,2 @@ var entry = entries[index];

}
/**

@@ -413,6 +297,7 @@ * Removes all key-value entries from the hash.

*/
function hashClear() {
this.__data__ = nativeCreate ? nativeCreate(null) : {};
}
/**

@@ -428,6 +313,7 @@ * Removes `key` and its value from the hash.

*/
function hashDelete(key) {
return this.has(key) && delete this.__data__[key];
}
/**

@@ -442,4 +328,7 @@ * Gets the hash value for `key`.

*/
function hashGet(key) {
var data = this.__data__;
if (nativeCreate) {

@@ -449,5 +338,5 @@ var result = data[key];

}
return hasOwnProperty.call(data, key) ? data[key] : undefined;
}
/**

@@ -462,2 +351,4 @@ * Checks if a hash value for `key` exists.

*/
function hashHas(key) {

@@ -467,3 +358,2 @@ var data = this.__data__;

}
/**

@@ -479,9 +369,11 @@ * Sets the hash `key` to `value`.

*/
function hashSet(key, value) {
var data = this.__data__;
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
return this;
}
} // Add methods to `Hash`.
// Add methods to `Hash`.
Hash.prototype.clear = hashClear;

@@ -492,3 +384,2 @@ Hash.prototype['delete'] = hashDelete;

Hash.prototype.set = hashSet;
/**

@@ -501,7 +392,8 @@ * Creates an list cache object.

*/
function ListCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
this.clear();
while (++index < length) {

@@ -512,3 +404,2 @@ var entry = entries[index];

}
/**

@@ -521,6 +412,7 @@ * Removes all key-value entries from the list cache.

*/
function listCacheClear() {
this.__data__ = [];
}
/**

@@ -535,2 +427,4 @@ * Removes `key` and its value from the list cache.

*/
function listCacheDelete(key) {

@@ -543,3 +437,5 @@ var data = this.__data__,

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

@@ -550,5 +446,5 @@ data.pop();

}
return true;
}
/**

@@ -563,9 +459,9 @@ * Gets the list cache value for `key`.

*/
function listCacheGet(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
return index < 0 ? undefined : data[index][1];
}
/**

@@ -580,6 +476,7 @@ * Checks if a list cache value for `key` exists.

*/
function listCacheHas(key) {
return assocIndexOf(this.__data__, key) > -1;
}
/**

@@ -595,2 +492,4 @@ * Sets the list cache `key` to `value`.

*/
function listCacheSet(key, value) {

@@ -605,6 +504,7 @@ var data = this.__data__,

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

@@ -615,3 +515,2 @@ ListCache.prototype['delete'] = listCacheDelete;

ListCache.prototype.set = listCacheSet;
/**

@@ -624,7 +523,8 @@ * Creates a map cache object to store key-value pairs.

*/
function MapCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
this.clear();
while (++index < length) {

@@ -635,3 +535,2 @@ var entry = entries[index];

}
/**

@@ -644,10 +543,11 @@ * Removes all key-value entries from the map.

*/
function mapCacheClear() {
this.__data__ = {
'hash': new Hash,
'map': new (Map || ListCache),
'string': new Hash
hash: new Hash(),
map: new (Map || ListCache)(),
string: new Hash()
};
}
/**

@@ -662,6 +562,7 @@ * Removes `key` and its value from the map.

*/
function mapCacheDelete(key) {
return getMapData(this, key)['delete'](key);
}
/**

@@ -676,6 +577,7 @@ * Gets the map value for `key`.

*/
function mapCacheGet(key) {
return getMapData(this, key).get(key);
}
/**

@@ -690,6 +592,7 @@ * Checks if a map value for `key` exists.

*/
function mapCacheHas(key) {
return getMapData(this, key).has(key);
}
/**

@@ -705,8 +608,10 @@ * Sets the map `key` to `value`.

*/
function mapCacheSet(key, value) {
getMapData(this, key).set(key, value);
return this;
}
} // Add methods to `MapCache`.
// Add methods to `MapCache`.
MapCache.prototype.clear = mapCacheClear;

@@ -717,3 +622,2 @@ MapCache.prototype['delete'] = mapCacheDelete;

MapCache.prototype.set = mapCacheSet;
/**

@@ -727,4 +631,6 @@ * Gets the index at which the `key` is found in `array` of key-value pairs.

*/
function assocIndexOf(array, key) {
var length = array.length;
while (length--) {

@@ -735,5 +641,5 @@ if (eq(array[length][0], key)) {

}
return -1;
}
/**

@@ -747,5 +653,6 @@ * The base implementation of `_.get` without support for default values.

*/
function baseGet(object, path) {
path = isKey(path, object) ? [path] : castPath(path);
var index = 0,

@@ -757,5 +664,5 @@ length = path.length;

}
return (index && index == length) ? object : undefined;
return index && index == length ? object : undefined;
}
/**

@@ -769,2 +676,4 @@ * The base implementation of `_.isNative` without bad shim checks.

*/
function baseIsNative(value) {

@@ -774,6 +683,6 @@ 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));
}
/**

@@ -787,2 +696,4 @@ * The base implementation of `_.toString` which doesn't convert nullish

*/
function baseToString(value) {

@@ -793,9 +704,10 @@ // 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;
var result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
}
/**

@@ -808,6 +720,7 @@ * Casts `value` to a path array if it's not one.

*/
function castPath(value) {
return isArray(value) ? value : stringToPath(value);
}
/**

@@ -821,9 +734,8 @@ * Gets the data for `map`.

*/
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;
}
/**

@@ -837,2 +749,4 @@ * Gets the native function at `key` of `object`.

*/
function getNative(object, key) {

@@ -842,3 +756,2 @@ var value = getValue(object, key);

}
/**

@@ -852,2 +765,4 @@ * Checks if `value` is a property name and not a property path.

*/
function isKey(value, object) {

@@ -857,11 +772,11 @@ if (isArray(value)) {

}
var type = typeof value;
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
value == null || isSymbol(value)) {
var type = _typeof(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);
}
/**

@@ -874,9 +789,9 @@ * Checks if `value` is suitable for use as unique object key.

*/
function isKeyable(value) {
var type = typeof value;
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
? (value !== '__proto__')
: (value === null);
var type = _typeof(value);
return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
}
/**

@@ -889,6 +804,7 @@ * Checks if `func` has its source masked.

*/
function isMasked(func) {
return !!maskSrcKey && (maskSrcKey in func);
return !!maskSrcKey && maskSrcKey in func;
}
/**

@@ -901,15 +817,17 @@ * Converts `string` to a property path array.

*/
var stringToPath = memoize(function(string) {
var stringToPath = memoize(function (string) {
string = toString(string);
var result = [];
var result = [];
if (reLeadingDot.test(string)) {
result.push('');
}
string.replace(rePropName, function(match, number, quote, string) {
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
string.replace(rePropName, function (match, number, quote, string) {
result.push(quote ? string.replace(reEscapeChar, '$1') : number || match);
});
return result;
});
/**

@@ -922,2 +840,3 @@ * Converts `value` to a string key if it's not a string or symbol.

*/
function toKey(value) {

@@ -927,6 +846,6 @@ if (typeof value == 'string' || isSymbol(value)) {

}
var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
var result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
}
/**

@@ -939,2 +858,4 @@ * Converts `func` to its source code.

*/
function toSource(func) {

@@ -945,9 +866,10 @@ if (func != null) {

} catch (e) {}
try {
return (func + '');
return func + '';
} catch (e) {}
}
return '';
}
/**

@@ -997,7 +919,10 @@ * Creates a function that memoizes the result of `func`. If `resolver` is

*/
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() {
var memoized = function memoized() {
var args = arguments,

@@ -1010,2 +935,3 @@ key = resolver ? resolver.apply(this, args) : args[0],

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

@@ -1015,9 +941,9 @@ memoized.cache = cache.set(key, result);

};
memoized.cache = new (memoize.Cache || MapCache);
memoized.cache = new (memoize.Cache || MapCache)();
return memoized;
}
} // Assign cache to `_.memoize`.
// Assign cache to `_.memoize`.
memoize.Cache = MapCache;
/**

@@ -1055,6 +981,6 @@ * Performs a

*/
function eq(value, other) {
return value === other || (value !== value && other !== other);
return value === other || value !== value && other !== other;
}
/**

@@ -1083,4 +1009,5 @@ * Checks if `value` is classified as an `Array` object.

*/
var isArray = Array.isArray;
/**

@@ -1103,2 +1030,3 @@ * Checks if `value` is classified as a `Function` object.

*/
function isFunction$1(value) {

@@ -1110,3 +1038,2 @@ // The use of `Object#toString` avoids issues with the `typeof` operator

}
/**

@@ -1137,7 +1064,9 @@ * Checks if `value` is the

*/
function isObject(value) {
var type = typeof value;
var type = _typeof(value);
return !!value && (type == 'object' || type == 'function');
}
/**

@@ -1167,6 +1096,7 @@ * Checks if `value` is object-like. A value is object-like if it's not `null`

*/
function isObjectLike(value) {
return !!value && typeof value == 'object';
return !!value && _typeof(value) == 'object';
}
/**

@@ -1189,7 +1119,7 @@ * Checks if `value` is classified as a `Symbol` primitive or object.

*/
function isSymbol(value) {
return typeof value == 'symbol' ||
(isObjectLike(value) && objectToString.call(value) == symbolTag);
return _typeof(value) == 'symbol' || isObjectLike(value) && objectToString.call(value) == symbolTag;
}
/**

@@ -1216,6 +1146,7 @@ * Converts `value` to a string. An empty string is returned for `null`

*/
function toString(value) {
return value == null ? '' : baseToString(value);
}
/**

@@ -1246,2 +1177,4 @@ * Gets the value at `path` of `object`. If the resolved value is

*/
function get(object, path, defaultValue) {

@@ -1252,7 +1185,125 @@ var result = object == null ? undefined : baseGet(object, path);

var lodash_get = get;
var get_1 = get;
var createDefaultValidationResult = function createDefaultValidationResult() {
return {
type: '',
succeeded: true,
message: ''
};
};
var createDefaultInternalValidationResult = function createDefaultInternalValidationResult() {
return {
key: '',
type: '',
succeeded: true,
message: ''
};
};
var createDefaultRecordValidationResult = function createDefaultRecordValidationResult() {
return {
succeeded: true,
recordErrors: {}
};
};
var createDefaultFormValidationResult = function createDefaultFormValidationResult() {
return {
succeeded: true,
fieldErrors: {},
recordErrors: {}
};
};
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();
return isPromise(result) ? result : Promise.resolve(result);
};
};
var mapToInternalFieldValidation = function mapToInternalFieldValidation(fieldValidation) {
return isFunction(fieldValidation) ? {
validator: convertFieldValidationToAsyncIfNeeded(fieldValidation),
message: void 0,
customArgs: void 0
} : {
validator: convertFieldValidationToAsyncIfNeeded(fieldValidation.validator),
customArgs: fieldValidation.customArgs,
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];
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];
return [fielId, mapToInternalValidationCollection(fieldValidations)];
});
return buildIntertalSchema(internalFieldValidations);
};
var mapToInternalRecordValidation = function mapToInternalRecordValidation(recordValidation) {
return isFunction(recordValidation) ? {
validator: convertRecordValidationToAsyncIfNeeded(recordValidation),
message: void 0
} : {
validator: convertRecordValidationToAsyncIfNeeded(recordValidation.validator),
message: recordValidation.message
};
};
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];
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, lodash_get(values, fieldId, undefined), values, schema);
return validateField(fieldId, get_1(values, fieldId, undefined), values, schema);
});

@@ -1503,3 +1554,3 @@ };

return Array.isArray(parsableArgs) ? parsableArgs.reduce(function (customMessage, arg) {
return customMessage.replace(arg, lodash_get(customArgs, getArgPath(arg), arg));
return customMessage.replace(arg, get_1(customArgs, getArgPath(arg), arg));
}, message) : message;

@@ -1506,0 +1557,0 @@ };

@@ -127,120 +127,2 @@ function _typeof(obj) {

var createDefaultValidationResult = function createDefaultValidationResult() {
return {
type: '',
succeeded: true,
message: ''
};
};
var createDefaultInternalValidationResult = function createDefaultInternalValidationResult() {
return {
key: '',
type: '',
succeeded: true,
message: ''
};
};
var createDefaultRecordValidationResult = function createDefaultRecordValidationResult() {
return {
succeeded: true,
recordErrors: {}
};
};
var createDefaultFormValidationResult = function createDefaultFormValidationResult() {
return {
succeeded: true,
fieldErrors: {},
recordErrors: {}
};
};
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();
return isPromise(result) ? result : Promise.resolve(result);
};
};
var mapToInternalFieldValidation = function mapToInternalFieldValidation(fieldValidation) {
return isFunction(fieldValidation) ? {
validator: convertFieldValidationToAsyncIfNeeded(fieldValidation),
message: void 0,
customArgs: void 0
} : {
validator: convertFieldValidationToAsyncIfNeeded(fieldValidation.validator),
customArgs: fieldValidation.customArgs,
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];
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];
return [fielId, mapToInternalValidationCollection(fieldValidations)];
});
return buildIntertalSchema(internalFieldValidations);
};
var mapToInternalRecordValidation = function mapToInternalRecordValidation(recordValidation) {
return isFunction(recordValidation) ? {
validator: convertRecordValidationToAsyncIfNeeded(recordValidation),
message: void 0
} : {
validator: convertRecordValidationToAsyncIfNeeded(recordValidation.validator),
message: recordValidation.message
};
};
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];
return [fielId, mapToInternalValidationCollection$1(recordValidations)];
});
return buildIntertalSchema$1(internalRecordValidations);
};
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

@@ -258,16 +140,17 @@

/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to stand-in for `undefined` hash values. */
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/** Used as references for various `Number` constants. */
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
/** `Object#toString` result references. */
/** `Object#toString` result references. */
var funcTag = '[object Function]',
genTag = '[object GeneratorFunction]',
symbolTag = '[object Symbol]';
/** Used to match property names within property paths. */
/** Used to match property names within property paths. */
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,

@@ -277,3 +160,2 @@ reIsPlainProp = /^\w*$/,

rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
/**

@@ -283,19 +165,19 @@ * Used to match `RegExp`

*/
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
/** Used to match backslashes in property paths. */
/** Used to match backslashes in property paths. */
var reEscapeChar = /\\(\\)?/g;
/** Used to detect host constructors (Safari). */
/** Used to detect host constructors (Safari). */
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 == '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')();
/**

@@ -309,6 +191,6 @@ * Gets the value at `key` of `object`.

*/
function getValue(object, key) {
return object == null ? undefined : object[key];
}
/**

@@ -321,2 +203,4 @@ * Checks if `value` is a host object in IE < 9.

*/
function isHostObject(value) {

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

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

@@ -332,25 +217,27 @@ try {

}
return result;
}
/** Used for built-in method references. */
/** Used for built-in method references. */
var arrayProto = Array.prototype,
funcProto = Function.prototype,
objectProto = Object.prototype;
/** Used to detect overreaching core-js shims. */
/** Used to detect overreaching core-js shims. */
var coreJsData = root['__core-js_shared__'];
/** Used to detect methods masquerading as native. */
/** Used to detect methods masquerading as native. */
var maskSrcKey = (function() {
var maskSrcKey = function () {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
return uid ? ('Symbol(src)_1.' + uid) : '';
}());
return uid ? 'Symbol(src)_1.' + uid : '';
}();
/** Used to resolve the decompiled source of functions. */
/** Used to resolve the decompiled source of functions. */
var funcToString = funcProto.toString;
/** Used to check objects for own properties. */
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**

@@ -361,22 +248,19 @@ * Used to resolve the

*/
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$1 = root.Symbol,
var _Symbol = root.Symbol,
splice = arrayProto.splice;
/* Built-in method references that are verified to be native. */
/* Built-in method references that are verified to be native. */
var Map = getNative(root, 'Map'),
nativeCreate = getNative(Object, 'create');
/** Used to convert symbols to primitives and strings. */
/** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
symbolToString = symbolProto ? symbolProto.toString : undefined;
/**

@@ -389,7 +273,8 @@ * Creates a hash object.

*/
function Hash(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
this.clear();
while (++index < length) {

@@ -400,3 +285,2 @@ var entry = entries[index];

}
/**

@@ -409,6 +293,7 @@ * Removes all key-value entries from the hash.

*/
function hashClear() {
this.__data__ = nativeCreate ? nativeCreate(null) : {};
}
/**

@@ -424,6 +309,7 @@ * Removes `key` and its value from the hash.

*/
function hashDelete(key) {
return this.has(key) && delete this.__data__[key];
}
/**

@@ -438,4 +324,7 @@ * Gets the hash value for `key`.

*/
function hashGet(key) {
var data = this.__data__;
if (nativeCreate) {

@@ -445,5 +334,5 @@ var result = data[key];

}
return hasOwnProperty.call(data, key) ? data[key] : undefined;
}
/**

@@ -458,2 +347,4 @@ * Checks if a hash value for `key` exists.

*/
function hashHas(key) {

@@ -463,3 +354,2 @@ var data = this.__data__;

}
/**

@@ -475,9 +365,11 @@ * Sets the hash `key` to `value`.

*/
function hashSet(key, value) {
var data = this.__data__;
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
return this;
}
} // Add methods to `Hash`.
// Add methods to `Hash`.
Hash.prototype.clear = hashClear;

@@ -488,3 +380,2 @@ Hash.prototype['delete'] = hashDelete;

Hash.prototype.set = hashSet;
/**

@@ -497,7 +388,8 @@ * Creates an list cache object.

*/
function ListCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
this.clear();
while (++index < length) {

@@ -508,3 +400,2 @@ var entry = entries[index];

}
/**

@@ -517,6 +408,7 @@ * Removes all key-value entries from the list cache.

*/
function listCacheClear() {
this.__data__ = [];
}
/**

@@ -531,2 +423,4 @@ * Removes `key` and its value from the list cache.

*/
function listCacheDelete(key) {

@@ -539,3 +433,5 @@ var data = this.__data__,

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

@@ -546,5 +442,5 @@ data.pop();

}
return true;
}
/**

@@ -559,9 +455,9 @@ * Gets the list cache value for `key`.

*/
function listCacheGet(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
return index < 0 ? undefined : data[index][1];
}
/**

@@ -576,6 +472,7 @@ * Checks if a list cache value for `key` exists.

*/
function listCacheHas(key) {
return assocIndexOf(this.__data__, key) > -1;
}
/**

@@ -591,2 +488,4 @@ * Sets the list cache `key` to `value`.

*/
function listCacheSet(key, value) {

@@ -601,6 +500,7 @@ var data = this.__data__,

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

@@ -611,3 +511,2 @@ ListCache.prototype['delete'] = listCacheDelete;

ListCache.prototype.set = listCacheSet;
/**

@@ -620,7 +519,8 @@ * Creates a map cache object to store key-value pairs.

*/
function MapCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
this.clear();
while (++index < length) {

@@ -631,3 +531,2 @@ var entry = entries[index];

}
/**

@@ -640,10 +539,11 @@ * Removes all key-value entries from the map.

*/
function mapCacheClear() {
this.__data__ = {
'hash': new Hash,
'map': new (Map || ListCache),
'string': new Hash
hash: new Hash(),
map: new (Map || ListCache)(),
string: new Hash()
};
}
/**

@@ -658,6 +558,7 @@ * Removes `key` and its value from the map.

*/
function mapCacheDelete(key) {
return getMapData(this, key)['delete'](key);
}
/**

@@ -672,6 +573,7 @@ * Gets the map value for `key`.

*/
function mapCacheGet(key) {
return getMapData(this, key).get(key);
}
/**

@@ -686,6 +588,7 @@ * Checks if a map value for `key` exists.

*/
function mapCacheHas(key) {
return getMapData(this, key).has(key);
}
/**

@@ -701,8 +604,10 @@ * Sets the map `key` to `value`.

*/
function mapCacheSet(key, value) {
getMapData(this, key).set(key, value);
return this;
}
} // Add methods to `MapCache`.
// Add methods to `MapCache`.
MapCache.prototype.clear = mapCacheClear;

@@ -713,3 +618,2 @@ MapCache.prototype['delete'] = mapCacheDelete;

MapCache.prototype.set = mapCacheSet;
/**

@@ -723,4 +627,6 @@ * Gets the index at which the `key` is found in `array` of key-value pairs.

*/
function assocIndexOf(array, key) {
var length = array.length;
while (length--) {

@@ -731,5 +637,5 @@ if (eq(array[length][0], key)) {

}
return -1;
}
/**

@@ -743,5 +649,6 @@ * The base implementation of `_.get` without support for default values.

*/
function baseGet(object, path) {
path = isKey(path, object) ? [path] : castPath(path);
var index = 0,

@@ -753,5 +660,5 @@ length = path.length;

}
return (index && index == length) ? object : undefined;
return index && index == length ? object : undefined;
}
/**

@@ -765,2 +672,4 @@ * The base implementation of `_.isNative` without bad shim checks.

*/
function baseIsNative(value) {

@@ -770,6 +679,6 @@ 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));
}
/**

@@ -783,2 +692,4 @@ * The base implementation of `_.toString` which doesn't convert nullish

*/
function baseToString(value) {

@@ -789,9 +700,10 @@ // 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;
var result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
}
/**

@@ -804,6 +716,7 @@ * Casts `value` to a path array if it's not one.

*/
function castPath(value) {
return isArray(value) ? value : stringToPath(value);
}
/**

@@ -817,9 +730,8 @@ * Gets the data for `map`.

*/
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;
}
/**

@@ -833,2 +745,4 @@ * Gets the native function at `key` of `object`.

*/
function getNative(object, key) {

@@ -838,3 +752,2 @@ var value = getValue(object, key);

}
/**

@@ -848,2 +761,4 @@ * Checks if `value` is a property name and not a property path.

*/
function isKey(value, object) {

@@ -853,11 +768,11 @@ if (isArray(value)) {

}
var type = typeof value;
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
value == null || isSymbol(value)) {
var type = _typeof(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);
}
/**

@@ -870,9 +785,9 @@ * Checks if `value` is suitable for use as unique object key.

*/
function isKeyable(value) {
var type = typeof value;
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
? (value !== '__proto__')
: (value === null);
var type = _typeof(value);
return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
}
/**

@@ -885,6 +800,7 @@ * Checks if `func` has its source masked.

*/
function isMasked(func) {
return !!maskSrcKey && (maskSrcKey in func);
return !!maskSrcKey && maskSrcKey in func;
}
/**

@@ -897,15 +813,17 @@ * Converts `string` to a property path array.

*/
var stringToPath = memoize(function(string) {
var stringToPath = memoize(function (string) {
string = toString(string);
var result = [];
var result = [];
if (reLeadingDot.test(string)) {
result.push('');
}
string.replace(rePropName, function(match, number, quote, string) {
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
string.replace(rePropName, function (match, number, quote, string) {
result.push(quote ? string.replace(reEscapeChar, '$1') : number || match);
});
return result;
});
/**

@@ -918,2 +836,3 @@ * Converts `value` to a string key if it's not a string or symbol.

*/
function toKey(value) {

@@ -923,6 +842,6 @@ if (typeof value == 'string' || isSymbol(value)) {

}
var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
var result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
}
/**

@@ -935,2 +854,4 @@ * Converts `func` to its source code.

*/
function toSource(func) {

@@ -941,9 +862,10 @@ if (func != null) {

} catch (e) {}
try {
return (func + '');
return func + '';
} catch (e) {}
}
return '';
}
/**

@@ -993,7 +915,10 @@ * Creates a function that memoizes the result of `func`. If `resolver` is

*/
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() {
var memoized = function memoized() {
var args = arguments,

@@ -1006,2 +931,3 @@ key = resolver ? resolver.apply(this, args) : args[0],

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

@@ -1011,9 +937,9 @@ memoized.cache = cache.set(key, result);

};
memoized.cache = new (memoize.Cache || MapCache);
memoized.cache = new (memoize.Cache || MapCache)();
return memoized;
}
} // Assign cache to `_.memoize`.
// Assign cache to `_.memoize`.
memoize.Cache = MapCache;
/**

@@ -1051,6 +977,6 @@ * Performs a

*/
function eq(value, other) {
return value === other || (value !== value && other !== other);
return value === other || value !== value && other !== other;
}
/**

@@ -1079,4 +1005,5 @@ * Checks if `value` is classified as an `Array` object.

*/
var isArray = Array.isArray;
/**

@@ -1099,2 +1026,3 @@ * Checks if `value` is classified as a `Function` object.

*/
function isFunction$1(value) {

@@ -1106,3 +1034,2 @@ // The use of `Object#toString` avoids issues with the `typeof` operator

}
/**

@@ -1133,7 +1060,9 @@ * Checks if `value` is the

*/
function isObject(value) {
var type = typeof value;
var type = _typeof(value);
return !!value && (type == 'object' || type == 'function');
}
/**

@@ -1163,6 +1092,7 @@ * Checks if `value` is object-like. A value is object-like if it's not `null`

*/
function isObjectLike(value) {
return !!value && typeof value == 'object';
return !!value && _typeof(value) == 'object';
}
/**

@@ -1185,7 +1115,7 @@ * Checks if `value` is classified as a `Symbol` primitive or object.

*/
function isSymbol(value) {
return typeof value == 'symbol' ||
(isObjectLike(value) && objectToString.call(value) == symbolTag);
return _typeof(value) == 'symbol' || isObjectLike(value) && objectToString.call(value) == symbolTag;
}
/**

@@ -1212,6 +1142,7 @@ * Converts `value` to a string. An empty string is returned for `null`

*/
function toString(value) {
return value == null ? '' : baseToString(value);
}
/**

@@ -1242,2 +1173,4 @@ * Gets the value at `path` of `object`. If the resolved value is

*/
function get(object, path, defaultValue) {

@@ -1248,7 +1181,125 @@ var result = object == null ? undefined : baseGet(object, path);

var lodash_get = get;
var get_1 = get;
var createDefaultValidationResult = function createDefaultValidationResult() {
return {
type: '',
succeeded: true,
message: ''
};
};
var createDefaultInternalValidationResult = function createDefaultInternalValidationResult() {
return {
key: '',
type: '',
succeeded: true,
message: ''
};
};
var createDefaultRecordValidationResult = function createDefaultRecordValidationResult() {
return {
succeeded: true,
recordErrors: {}
};
};
var createDefaultFormValidationResult = function createDefaultFormValidationResult() {
return {
succeeded: true,
fieldErrors: {},
recordErrors: {}
};
};
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();
return isPromise(result) ? result : Promise.resolve(result);
};
};
var mapToInternalFieldValidation = function mapToInternalFieldValidation(fieldValidation) {
return isFunction(fieldValidation) ? {
validator: convertFieldValidationToAsyncIfNeeded(fieldValidation),
message: void 0,
customArgs: void 0
} : {
validator: convertFieldValidationToAsyncIfNeeded(fieldValidation.validator),
customArgs: fieldValidation.customArgs,
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];
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];
return [fielId, mapToInternalValidationCollection(fieldValidations)];
});
return buildIntertalSchema(internalFieldValidations);
};
var mapToInternalRecordValidation = function mapToInternalRecordValidation(recordValidation) {
return isFunction(recordValidation) ? {
validator: convertRecordValidationToAsyncIfNeeded(recordValidation),
message: void 0
} : {
validator: convertRecordValidationToAsyncIfNeeded(recordValidation.validator),
message: recordValidation.message
};
};
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];
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, lodash_get(values, fieldId, undefined), values, schema);
return validateField(fieldId, get_1(values, fieldId, undefined), values, schema);
});

@@ -1499,3 +1550,3 @@ };

return Array.isArray(parsableArgs) ? parsableArgs.reduce(function (customMessage, arg) {
return customMessage.replace(arg, lodash_get(customArgs, getArgPath(arg), arg));
return customMessage.replace(arg, get_1(customArgs, getArgPath(arg), arg));
}, message) : message;

@@ -1502,0 +1553,0 @@ };

@@ -133,120 +133,2 @@ (function (global, factory) {

var createDefaultValidationResult = function createDefaultValidationResult() {
return {
type: '',
succeeded: true,
message: ''
};
};
var createDefaultInternalValidationResult = function createDefaultInternalValidationResult() {
return {
key: '',
type: '',
succeeded: true,
message: ''
};
};
var createDefaultRecordValidationResult = function createDefaultRecordValidationResult() {
return {
succeeded: true,
recordErrors: {}
};
};
var createDefaultFormValidationResult = function createDefaultFormValidationResult() {
return {
succeeded: true,
fieldErrors: {},
recordErrors: {}
};
};
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();
return isPromise(result) ? result : Promise.resolve(result);
};
};
var mapToInternalFieldValidation = function mapToInternalFieldValidation(fieldValidation) {
return isFunction(fieldValidation) ? {
validator: convertFieldValidationToAsyncIfNeeded(fieldValidation),
message: void 0,
customArgs: void 0
} : {
validator: convertFieldValidationToAsyncIfNeeded(fieldValidation.validator),
customArgs: fieldValidation.customArgs,
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];
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];
return [fielId, mapToInternalValidationCollection(fieldValidations)];
});
return buildIntertalSchema(internalFieldValidations);
};
var mapToInternalRecordValidation = function mapToInternalRecordValidation(recordValidation) {
return isFunction(recordValidation) ? {
validator: convertRecordValidationToAsyncIfNeeded(recordValidation),
message: void 0
} : {
validator: convertRecordValidationToAsyncIfNeeded(recordValidation.validator),
message: recordValidation.message
};
};
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];
return [fielId, mapToInternalValidationCollection$1(recordValidations)];
});
return buildIntertalSchema$1(internalRecordValidations);
};
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

@@ -264,16 +146,17 @@

/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to stand-in for `undefined` hash values. */
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/** Used as references for various `Number` constants. */
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
/** `Object#toString` result references. */
/** `Object#toString` result references. */
var funcTag = '[object Function]',
genTag = '[object GeneratorFunction]',
symbolTag = '[object Symbol]';
/** Used to match property names within property paths. */
/** Used to match property names within property paths. */
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,

@@ -283,3 +166,2 @@ reIsPlainProp = /^\w*$/,

rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
/**

@@ -289,19 +171,19 @@ * Used to match `RegExp`

*/
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
/** Used to match backslashes in property paths. */
/** Used to match backslashes in property paths. */
var reEscapeChar = /\\(\\)?/g;
/** Used to detect host constructors (Safari). */
/** Used to detect host constructors (Safari). */
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 == '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')();
/**

@@ -315,6 +197,6 @@ * Gets the value at `key` of `object`.

*/
function getValue(object, key) {
return object == null ? undefined : object[key];
}
/**

@@ -327,2 +209,4 @@ * Checks if `value` is a host object in IE < 9.

*/
function isHostObject(value) {

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

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

@@ -338,25 +223,27 @@ try {

}
return result;
}
/** Used for built-in method references. */
/** Used for built-in method references. */
var arrayProto = Array.prototype,
funcProto = Function.prototype,
objectProto = Object.prototype;
/** Used to detect overreaching core-js shims. */
/** Used to detect overreaching core-js shims. */
var coreJsData = root['__core-js_shared__'];
/** Used to detect methods masquerading as native. */
/** Used to detect methods masquerading as native. */
var maskSrcKey = (function() {
var maskSrcKey = function () {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
return uid ? ('Symbol(src)_1.' + uid) : '';
}());
return uid ? 'Symbol(src)_1.' + uid : '';
}();
/** Used to resolve the decompiled source of functions. */
/** Used to resolve the decompiled source of functions. */
var funcToString = funcProto.toString;
/** Used to check objects for own properties. */
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**

@@ -367,22 +254,19 @@ * Used to resolve the

*/
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$1 = root.Symbol,
var _Symbol = root.Symbol,
splice = arrayProto.splice;
/* Built-in method references that are verified to be native. */
/* Built-in method references that are verified to be native. */
var Map = getNative(root, 'Map'),
nativeCreate = getNative(Object, 'create');
/** Used to convert symbols to primitives and strings. */
/** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
symbolToString = symbolProto ? symbolProto.toString : undefined;
/**

@@ -395,7 +279,8 @@ * Creates a hash object.

*/
function Hash(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
this.clear();
while (++index < length) {

@@ -406,3 +291,2 @@ var entry = entries[index];

}
/**

@@ -415,6 +299,7 @@ * Removes all key-value entries from the hash.

*/
function hashClear() {
this.__data__ = nativeCreate ? nativeCreate(null) : {};
}
/**

@@ -430,6 +315,7 @@ * Removes `key` and its value from the hash.

*/
function hashDelete(key) {
return this.has(key) && delete this.__data__[key];
}
/**

@@ -444,4 +330,7 @@ * Gets the hash value for `key`.

*/
function hashGet(key) {
var data = this.__data__;
if (nativeCreate) {

@@ -451,5 +340,5 @@ var result = data[key];

}
return hasOwnProperty.call(data, key) ? data[key] : undefined;
}
/**

@@ -464,2 +353,4 @@ * Checks if a hash value for `key` exists.

*/
function hashHas(key) {

@@ -469,3 +360,2 @@ var data = this.__data__;

}
/**

@@ -481,9 +371,11 @@ * Sets the hash `key` to `value`.

*/
function hashSet(key, value) {
var data = this.__data__;
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
return this;
}
} // Add methods to `Hash`.
// Add methods to `Hash`.
Hash.prototype.clear = hashClear;

@@ -494,3 +386,2 @@ Hash.prototype['delete'] = hashDelete;

Hash.prototype.set = hashSet;
/**

@@ -503,7 +394,8 @@ * Creates an list cache object.

*/
function ListCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
this.clear();
while (++index < length) {

@@ -514,3 +406,2 @@ var entry = entries[index];

}
/**

@@ -523,6 +414,7 @@ * Removes all key-value entries from the list cache.

*/
function listCacheClear() {
this.__data__ = [];
}
/**

@@ -537,2 +429,4 @@ * Removes `key` and its value from the list cache.

*/
function listCacheDelete(key) {

@@ -545,3 +439,5 @@ var data = this.__data__,

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

@@ -552,5 +448,5 @@ data.pop();

}
return true;
}
/**

@@ -565,9 +461,9 @@ * Gets the list cache value for `key`.

*/
function listCacheGet(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
return index < 0 ? undefined : data[index][1];
}
/**

@@ -582,6 +478,7 @@ * Checks if a list cache value for `key` exists.

*/
function listCacheHas(key) {
return assocIndexOf(this.__data__, key) > -1;
}
/**

@@ -597,2 +494,4 @@ * Sets the list cache `key` to `value`.

*/
function listCacheSet(key, value) {

@@ -607,6 +506,7 @@ var data = this.__data__,

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

@@ -617,3 +517,2 @@ ListCache.prototype['delete'] = listCacheDelete;

ListCache.prototype.set = listCacheSet;
/**

@@ -626,7 +525,8 @@ * Creates a map cache object to store key-value pairs.

*/
function MapCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
this.clear();
while (++index < length) {

@@ -637,3 +537,2 @@ var entry = entries[index];

}
/**

@@ -646,10 +545,11 @@ * Removes all key-value entries from the map.

*/
function mapCacheClear() {
this.__data__ = {
'hash': new Hash,
'map': new (Map || ListCache),
'string': new Hash
hash: new Hash(),
map: new (Map || ListCache)(),
string: new Hash()
};
}
/**

@@ -664,6 +564,7 @@ * Removes `key` and its value from the map.

*/
function mapCacheDelete(key) {
return getMapData(this, key)['delete'](key);
}
/**

@@ -678,6 +579,7 @@ * Gets the map value for `key`.

*/
function mapCacheGet(key) {
return getMapData(this, key).get(key);
}
/**

@@ -692,6 +594,7 @@ * Checks if a map value for `key` exists.

*/
function mapCacheHas(key) {
return getMapData(this, key).has(key);
}
/**

@@ -707,8 +610,10 @@ * Sets the map `key` to `value`.

*/
function mapCacheSet(key, value) {
getMapData(this, key).set(key, value);
return this;
}
} // Add methods to `MapCache`.
// Add methods to `MapCache`.
MapCache.prototype.clear = mapCacheClear;

@@ -719,3 +624,2 @@ MapCache.prototype['delete'] = mapCacheDelete;

MapCache.prototype.set = mapCacheSet;
/**

@@ -729,4 +633,6 @@ * Gets the index at which the `key` is found in `array` of key-value pairs.

*/
function assocIndexOf(array, key) {
var length = array.length;
while (length--) {

@@ -737,5 +643,5 @@ if (eq(array[length][0], key)) {

}
return -1;
}
/**

@@ -749,5 +655,6 @@ * The base implementation of `_.get` without support for default values.

*/
function baseGet(object, path) {
path = isKey(path, object) ? [path] : castPath(path);
var index = 0,

@@ -759,5 +666,5 @@ length = path.length;

}
return (index && index == length) ? object : undefined;
return index && index == length ? object : undefined;
}
/**

@@ -771,2 +678,4 @@ * The base implementation of `_.isNative` without bad shim checks.

*/
function baseIsNative(value) {

@@ -776,6 +685,6 @@ 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));
}
/**

@@ -789,2 +698,4 @@ * The base implementation of `_.toString` which doesn't convert nullish

*/
function baseToString(value) {

@@ -795,9 +706,10 @@ // 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;
var result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
}
/**

@@ -810,6 +722,7 @@ * Casts `value` to a path array if it's not one.

*/
function castPath(value) {
return isArray(value) ? value : stringToPath(value);
}
/**

@@ -823,9 +736,8 @@ * Gets the data for `map`.

*/
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;
}
/**

@@ -839,2 +751,4 @@ * Gets the native function at `key` of `object`.

*/
function getNative(object, key) {

@@ -844,3 +758,2 @@ var value = getValue(object, key);

}
/**

@@ -854,2 +767,4 @@ * Checks if `value` is a property name and not a property path.

*/
function isKey(value, object) {

@@ -859,11 +774,11 @@ if (isArray(value)) {

}
var type = typeof value;
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
value == null || isSymbol(value)) {
var type = _typeof(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);
}
/**

@@ -876,9 +791,9 @@ * Checks if `value` is suitable for use as unique object key.

*/
function isKeyable(value) {
var type = typeof value;
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
? (value !== '__proto__')
: (value === null);
var type = _typeof(value);
return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
}
/**

@@ -891,6 +806,7 @@ * Checks if `func` has its source masked.

*/
function isMasked(func) {
return !!maskSrcKey && (maskSrcKey in func);
return !!maskSrcKey && maskSrcKey in func;
}
/**

@@ -903,15 +819,17 @@ * Converts `string` to a property path array.

*/
var stringToPath = memoize(function(string) {
var stringToPath = memoize(function (string) {
string = toString(string);
var result = [];
var result = [];
if (reLeadingDot.test(string)) {
result.push('');
}
string.replace(rePropName, function(match, number, quote, string) {
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
string.replace(rePropName, function (match, number, quote, string) {
result.push(quote ? string.replace(reEscapeChar, '$1') : number || match);
});
return result;
});
/**

@@ -924,2 +842,3 @@ * Converts `value` to a string key if it's not a string or symbol.

*/
function toKey(value) {

@@ -929,6 +848,6 @@ if (typeof value == 'string' || isSymbol(value)) {

}
var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
var result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
}
/**

@@ -941,2 +860,4 @@ * Converts `func` to its source code.

*/
function toSource(func) {

@@ -947,9 +868,10 @@ if (func != null) {

} catch (e) {}
try {
return (func + '');
return func + '';
} catch (e) {}
}
return '';
}
/**

@@ -999,7 +921,10 @@ * Creates a function that memoizes the result of `func`. If `resolver` is

*/
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() {
var memoized = function memoized() {
var args = arguments,

@@ -1012,2 +937,3 @@ key = resolver ? resolver.apply(this, args) : args[0],

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

@@ -1017,9 +943,9 @@ memoized.cache = cache.set(key, result);

};
memoized.cache = new (memoize.Cache || MapCache);
memoized.cache = new (memoize.Cache || MapCache)();
return memoized;
}
} // Assign cache to `_.memoize`.
// Assign cache to `_.memoize`.
memoize.Cache = MapCache;
/**

@@ -1057,6 +983,6 @@ * Performs a

*/
function eq(value, other) {
return value === other || (value !== value && other !== other);
return value === other || value !== value && other !== other;
}
/**

@@ -1085,4 +1011,5 @@ * Checks if `value` is classified as an `Array` object.

*/
var isArray = Array.isArray;
/**

@@ -1105,2 +1032,3 @@ * Checks if `value` is classified as a `Function` object.

*/
function isFunction$1(value) {

@@ -1112,3 +1040,2 @@ // The use of `Object#toString` avoids issues with the `typeof` operator

}
/**

@@ -1139,7 +1066,9 @@ * Checks if `value` is the

*/
function isObject(value) {
var type = typeof value;
var type = _typeof(value);
return !!value && (type == 'object' || type == 'function');
}
/**

@@ -1169,6 +1098,7 @@ * Checks if `value` is object-like. A value is object-like if it's not `null`

*/
function isObjectLike(value) {
return !!value && typeof value == 'object';
return !!value && _typeof(value) == 'object';
}
/**

@@ -1191,7 +1121,7 @@ * Checks if `value` is classified as a `Symbol` primitive or object.

*/
function isSymbol(value) {
return typeof value == 'symbol' ||
(isObjectLike(value) && objectToString.call(value) == symbolTag);
return _typeof(value) == 'symbol' || isObjectLike(value) && objectToString.call(value) == symbolTag;
}
/**

@@ -1218,6 +1148,7 @@ * Converts `value` to a string. An empty string is returned for `null`

*/
function toString(value) {
return value == null ? '' : baseToString(value);
}
/**

@@ -1248,2 +1179,4 @@ * Gets the value at `path` of `object`. If the resolved value is

*/
function get(object, path, defaultValue) {

@@ -1254,7 +1187,125 @@ var result = object == null ? undefined : baseGet(object, path);

var lodash_get = get;
var get_1 = get;
var createDefaultValidationResult = function createDefaultValidationResult() {
return {
type: '',
succeeded: true,
message: ''
};
};
var createDefaultInternalValidationResult = function createDefaultInternalValidationResult() {
return {
key: '',
type: '',
succeeded: true,
message: ''
};
};
var createDefaultRecordValidationResult = function createDefaultRecordValidationResult() {
return {
succeeded: true,
recordErrors: {}
};
};
var createDefaultFormValidationResult = function createDefaultFormValidationResult() {
return {
succeeded: true,
fieldErrors: {},
recordErrors: {}
};
};
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();
return isPromise(result) ? result : Promise.resolve(result);
};
};
var mapToInternalFieldValidation = function mapToInternalFieldValidation(fieldValidation) {
return isFunction(fieldValidation) ? {
validator: convertFieldValidationToAsyncIfNeeded(fieldValidation),
message: void 0,
customArgs: void 0
} : {
validator: convertFieldValidationToAsyncIfNeeded(fieldValidation.validator),
customArgs: fieldValidation.customArgs,
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];
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];
return [fielId, mapToInternalValidationCollection(fieldValidations)];
});
return buildIntertalSchema(internalFieldValidations);
};
var mapToInternalRecordValidation = function mapToInternalRecordValidation(recordValidation) {
return isFunction(recordValidation) ? {
validator: convertRecordValidationToAsyncIfNeeded(recordValidation),
message: void 0
} : {
validator: convertRecordValidationToAsyncIfNeeded(recordValidation.validator),
message: recordValidation.message
};
};
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];
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, lodash_get(values, fieldId, undefined), values, schema);
return validateField(fieldId, get_1(values, fieldId, undefined), values, schema);
});

@@ -1505,3 +1556,3 @@ };

return Array.isArray(parsableArgs) ? parsableArgs.reduce(function (customMessage, arg) {
return customMessage.replace(arg, lodash_get(customArgs, getArgPath(arg), arg));
return customMessage.replace(arg, get_1(customArgs, getArgPath(arg), arg));
}, message) : message;

@@ -1508,0 +1559,0 @@ };

@@ -15,2 +15,2 @@ !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e=e||self)["@lemoncode/fonk"]={})}(this,(function(e){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function t(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function n(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,u=void 0;try{for(var i,a=e[Symbol.iterator]();!(n=(i=a.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,u=e}finally{try{n||null==a.return||a.return()}finally{if(o)throw u}}return t}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}

and limitations under the License.
***************************************************************************** */()}function o(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 u=function(e){return function(e){return Array.isArray(e)?e.length:0}(e)>0},i=function(e){return"function"==typeof e},a=function(e){return null==e},c=function(e){return e instanceof Promise},s=function(e){return Boolean(e)?Object.keys(e):[]},l=function(){return{type:"",succeeded:!0,message:""}},f=function(){return{succeeded:!0,recordErrors:{}}},d=function(){return{succeeded:!0,fieldErrors:{},recordErrors:{}}},p=function(e){return function(r){var t=e?e(r):{type:"",succeeded:!0,message:""};return c(t)?t:Promise.resolve(t)}},v=function(e){return function(r){var t=e?e(r):{type:"",succeeded:!0,message:""};return c(t)?t:Promise.resolve(t)}},h=function(e){return i(e)?{validator:p(e),message:void 0,customArgs:void 0}:{validator:p(e.validator),customArgs:e.customArgs,message:e.message}},y=function(e){return Array.isArray(e)?e.map(h):[]},m=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,y(o)]}));return t.reduce((function(e,r){var t=n(r,2),o=t[0],u=t[1];return e[o]=u,e}),{})},g=function(e){return i(e)?{validator:v(e),message:void 0}:{validator:v(e.validator),message:e.message}},_=function(e){return Array.isArray(e)?e.map(g):[]},b=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,_(o)]}));return t.reduce((function(e,r){var t=n(r,2),o=t[0],u=t[1];return e[o]=u,e}),{})},E="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},j="Expected a function",w="__lodash_hash_undefined__",O=1/0,A="[object Function]",S="[object GeneratorFunction]",P="[object Symbol]",x=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,k=/^\w*$/,V=/^\./,F=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,R=/\\(\\)?/g,T=/^\[object .+?Constructor\]$/,M="object"==typeof E&&E&&E.Object===Object&&E,$="object"==typeof self&&self&&self.Object===Object&&self,N=M||$||Function("return this")();var I,z=Array.prototype,L=Function.prototype,C=Object.prototype,D=N["__core-js_shared__"],G=(I=/[^.]+$/.exec(D&&D.keys&&D.keys.IE_PROTO||""))?"Symbol(src)_1."+I:"",U=L.toString,B=C.hasOwnProperty,H=C.toString,Z=RegExp("^"+U.call(B).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),q=N.Symbol,Q=z.splice,W=ie(N,"Map"),X=ie(Object,"create"),J=q?q.prototype:void 0,K=J?J.toString:void 0;function Y(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 ee(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 re(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 te(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 ne(e,r){for(var t,n=0,o=(r=function(e,r){if(le(e))return!1;var t=typeof e;if("number"==t||"symbol"==t||"boolean"==t||null==e||de(e))return!0;return k.test(e)||!x.test(e)||null!=r&&e in Object(r)}(r,e)?[r]:le(t=r)?t:ae(t)).length;null!=e&&n<o;)e=e[ce(r[n++])];return n&&n==o?e:void 0}function oe(e){return!(!fe(e)||(r=e,G&&G in r))&&(function(e){var r=fe(e)?H.call(e):"";return r==A||r==S}(e)||function(e){var r=!1;if(null!=e&&"function"!=typeof e.toString)try{r=!!(e+"")}catch(e){}return r}(e)?Z:T).test(function(e){if(null!=e){try{return U.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var r}function ue(e,r){var t,n,o=e.__data__;return("string"==(n=typeof(t=r))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==t:null===t)?o["string"==typeof r?"string":"hash"]:o.map}function ie(e,r){var t=function(e,r){return null==e?void 0:e[r]}(e,r);return oe(t)?t:void 0}Y.prototype.clear=function(){this.__data__=X?X(null):{}},Y.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Y.prototype.get=function(e){var r=this.__data__;if(X){var t=r[e];return t===w?void 0:t}return B.call(r,e)?r[e]:void 0},Y.prototype.has=function(e){var r=this.__data__;return X?void 0!==r[e]:B.call(r,e)},Y.prototype.set=function(e,r){return this.__data__[e]=X&&void 0===r?w:r,this},ee.prototype.clear=function(){this.__data__=[]},ee.prototype.delete=function(e){var r=this.__data__,t=te(r,e);return!(t<0)&&(t==r.length-1?r.pop():Q.call(r,t,1),!0)},ee.prototype.get=function(e){var r=this.__data__,t=te(r,e);return t<0?void 0:r[t][1]},ee.prototype.has=function(e){return te(this.__data__,e)>-1},ee.prototype.set=function(e,r){var t=this.__data__,n=te(t,e);return n<0?t.push([e,r]):t[n][1]=r,this},re.prototype.clear=function(){this.__data__={hash:new Y,map:new(W||ee),string:new Y}},re.prototype.delete=function(e){return ue(this,e).delete(e)},re.prototype.get=function(e){return ue(this,e).get(e)},re.prototype.has=function(e){return ue(this,e).has(e)},re.prototype.set=function(e,r){return ue(this,e).set(e,r),this};var ae=se((function(e){var r;e=null==(r=e)?"":function(e){if("string"==typeof e)return e;if(de(e))return K?K.call(e):"";var r=e+"";return"0"==r&&1/e==-O?"-0":r}(r);var t=[];return V.test(e)&&t.push(""),e.replace(F,(function(e,r,n,o){t.push(n?o.replace(R,"$1"):r||e)})),t}));function ce(e){if("string"==typeof e||de(e))return e;var r=e+"";return"0"==r&&1/e==-O?"-0":r}function se(e,r){if("function"!=typeof e||r&&"function"!=typeof r)throw new TypeError(j);var t=function(){var n=arguments,o=r?r.apply(this,n):n[0],u=t.cache;if(u.has(o))return u.get(o);var i=e.apply(this,n);return t.cache=u.set(o,i),i};return t.cache=new(se.Cache||re),t}se.Cache=re;var le=Array.isArray;function fe(e){var r=typeof e;return!!e&&("object"==r||"function"==r)}function de(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&H.call(e)==P}var pe=function(e,r,t){var n=null==e?void 0:ne(e,r);return void 0===n?t:n},ve=function(e,r,t,n){return e.map((function(e){return n(e,r,t)}))},he=function(e){var r=e;return e&&!a(e.succeeded)||(console.error("form-validators: One of the record validator is returning a non expected value."),r={key:"",type:"",succeeded:!0,message:""}),r},ye=function(e,r){return r.validator({values:e,message:r.message}).then(he)},me=function(e,r){return u(r)?function(e,r){return r.reduce((function(r,t){return r.then((function(r){return r.succeeded?ye(e,t):r}))}),ye(e,r[0]))}(e,r):Promise.resolve({key:"",type:"",succeeded:!0,message:""})},ge=function(e){var r=e;return e&&!a(e.succeeded)||(console.error("form-validators: One of the field validator is returning a non expected value."),r={key:"",type:"",succeeded:!0,message:""}),r},_e=function(e,r,t){return t.validator({value:e,values:r,customArgs:t.customArgs,message:t.message}).then(ge)},be=function(e,r,t){return u(t)?function(e,r,t){return t.reduce((function(t,n){return t.then((function(t){return t.succeeded?_e(e,r,n):t}))}),_e(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=o(r,["key"]);return e[t]=Object.assign({},n),e}),{})},we=function(e){var r={succeeded:!0,recordErrors:{}};return u(e)&&(r.succeeded=Ee(e),r.recordErrors=je(e)),r},Oe=function(e,r){return!a(r)&&!a(r[e])},Ae=function(e,r,t,n){return Oe(e,n)?be(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)?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:""})},Pe=function(e,r){var t=ve(s(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}))},xe=function(e,r,t){var o=function(e,r,t,n){return e.map((function(e){return n(e,pe(r,e,void 0),r,t)}))}(s(r),e,r,Ae),i=ve(s(t),e,t,Se);return Promise.all(o).then((function(e){return Promise.all(i).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(u(e)&&(t.succeeded=Ee(e),t.fieldErrors=je(e)),u(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}))},ke=function(){function e(r){!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(r)}var n,u,i;return n=e,(u=[{key:"setupValidationSchema",value:function(e){if(e&&"object"===r(e)){var t=e.record,n=e.field;n&&"object"===r(n)&&(this.fieldSchema=m(e.field)),t&&"object"===r(t)&&(this.recordSchema=b(e.record))}else console.error("ValidationSchema must be a valid object")}},{key:"validateField",value:function(e,r,t){return Ae(e,r,t,this.fieldSchema).then((function(e){e.key;var r=o(e,["key"]);return Object.assign({},r)}))}},{key:"validateRecord",value:function(e){return Pe(e,this.recordSchema)}},{key:"validateForm",value:function(e){return xe(e,this.fieldSchema,this.recordSchema)}}])&&t(n.prototype,u),i&&t(n,i),e}(),Ve=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,pe(r,function(e){return e.replace(/[{}]/g,"")}(t),t))}),e):e}(e,r):""},Fe="Please fill in this mandatory field.",Re={trim:!0},Te=function(e,r){return!!function(e){return null==e||""===e}(e)||r.test(e)},Me="Please enter a valid email address.",$e=/^(([^<>()\[\]\\.,;:\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,}))$/,Ne="Please provide a valid format.",Ie="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(Ie);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",Ge='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},Be="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 Fe=e},validator:function(e){var r=e.value,t=e.customArgs,n=void 0===t?Re:t,o=e.message,u=void 0===o?Fe:o,i=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:i,message:i?"":Ve(u,n),type:"REQUIRED"}}}),email:Object.freeze({__proto__:null,setErrorMessage:function(e){return Me=e},validator:function(e){var r=e.value,t=e.message,n=void 0===t?Me:t,o=function(e){return Te(e,$e)}(r);return{succeeded:o,message:o?"":n,type:"EMAIL"}}}),pattern:Object.freeze({__proto__:null,setErrorMessage:function(e){return Ne=e},validator:function(e){if(!e.customArgs)throw new Error(Ie);var r=e.value,t=e.customArgs,n=void 0===t?null:t,o=e.message,u=void 0===o?Ne:o,i=ze(n),a=Te(r,i);return{succeeded:a,message:a?"":Ve(u,n),type:"PATTERN"}}}),minLength:Object.freeze({__proto__:null,setErrorMessage:function(e){return De=e},validator:function(e){if(!e.customArgs)throw new Error(Ge);var r=e.value,t=e.customArgs,n=void 0===t?null:t,o=e.message,u=void 0===o?De:o,i=Ce(r,Le(n,Ge),Ue);return{succeeded:i,message:i?"":Ve(u,n),type:"MIN_LENGTH"}}}),maxLength:Object.freeze({__proto__:null,setErrorMessage:function(e){return Be=e},validator:function(e){if(!e.customArgs)throw new Error(He);var r=e.value,t=e.customArgs,n=void 0===t?null:t,o=e.message,u=void 0===o?Be:o,i=Ce(r,Le(n,He),Ze);return{succeeded:i,message:i?"":Ve(u,n),type:"MAX_LENGTH"}}})},Qe={validateField:Ae,validateRecord:Pe,validateForm:xe,mapToInternalFieldValidationSchema:m,mapToInternalRecordValidationSchema:b,FormValidation:ke};e.FormValidationExtended=Qe,e.Validators=qe,e.createDefaultFormValidationResult=d,e.createDefaultRecordValidationResult=f,e.createDefaultValidationResult=l,e.createFormValidation=function(e){return new ke(e)},e.parseMessageWithCustomArgs=Ve,Object.defineProperty(e,"__esModule",{value:!0})}));
***************************************************************************** */()}function o(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 u=function(e){return function(e){return Array.isArray(e)?e.length:0}(e)>0},i=function(e){return"function"==typeof e},a=function(e){return null==e},c=function(e){return e instanceof Promise},s=function(e){return Boolean(e)?Object.keys(e):[]},l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},f="Expected a function",d="__lodash_hash_undefined__",p=1/0,v="[object Function]",h="[object GeneratorFunction]",m="[object Symbol]",y=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,g=/^\w*$/,_=/^\./,b=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,E=/\\(\\)?/g,j=/^\[object .+?Constructor\]$/,w="object"==r(l)&&l&&l.Object===Object&&l,O="object"==("undefined"==typeof self?"undefined":r(self))&&self&&self.Object===Object&&self,A=w||O||Function("return this")();var S,P=Array.prototype,x=Function.prototype,k=Object.prototype,V=A["__core-js_shared__"],F=(S=/[^.]+$/.exec(V&&V.keys&&V.keys.IE_PROTO||""))?"Symbol(src)_1."+S:"",R=x.toString,T=k.hasOwnProperty,M=k.toString,$=RegExp("^"+R.call(T).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),N=A.Symbol,I=P.splice,z=W(A,"Map"),L=W(Object,"create"),C=N?N.prototype:void 0,D=C?C.toString:void 0;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){var r=-1,t=e?e.length:0;for(this.clear();++r<t;){var n=e[r];this.set(n[0],n[1])}}function H(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 Z(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||re(e))return!0;return g.test(e)||!y.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:Y(n=t)?n:X(n)).length;null!=e&&o<u;)e=e[J(t[o++])];return o&&o==u?e:void 0}function q(e){return!(!ee(e)||(r=e,F&&F in r))&&(function(e){var r=ee(e)?M.call(e):"";return r==v||r==h}(e)||function(e){var r=!1;if(null!=e&&"function"!=typeof e.toString)try{r=!!(e+"")}catch(e){}return r}(e)?$:j).test(function(e){if(null!=e){try{return R.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var r}function Q(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 W(e,r){var t=function(e,r){return null==e?void 0:e[r]}(e,r);return q(t)?t:void 0}G.prototype.clear=function(){this.__data__=L?L(null):{}},G.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},G.prototype.get=function(e){var r=this.__data__;if(L){var t=r[e];return t===d?void 0:t}return T.call(r,e)?r[e]:void 0},G.prototype.has=function(e){var r=this.__data__;return L?void 0!==r[e]:T.call(r,e)},G.prototype.set=function(e,r){return this.__data__[e]=L&&void 0===r?d:r,this},U.prototype.clear=function(){this.__data__=[]},U.prototype.delete=function(e){var r=this.__data__,t=H(r,e);return!(t<0)&&(t==r.length-1?r.pop():I.call(r,t,1),!0)},U.prototype.get=function(e){var r=this.__data__,t=H(r,e);return t<0?void 0:r[t][1]},U.prototype.has=function(e){return H(this.__data__,e)>-1},U.prototype.set=function(e,r){var t=this.__data__,n=H(t,e);return n<0?t.push([e,r]):t[n][1]=r,this},B.prototype.clear=function(){this.__data__={hash:new G,map:new(z||U),string:new G}},B.prototype.delete=function(e){return Q(this,e).delete(e)},B.prototype.get=function(e){return Q(this,e).get(e)},B.prototype.has=function(e){return Q(this,e).has(e)},B.prototype.set=function(e,r){return Q(this,e).set(e,r),this};var X=K((function(e){var r;e=null==(r=e)?"":function(e){if("string"==typeof e)return e;if(re(e))return D?D.call(e):"";var r=e+"";return"0"==r&&1/e==-p?"-0":r}(r);var t=[];return _.test(e)&&t.push(""),e.replace(b,(function(e,r,n,o){t.push(n?o.replace(E,"$1"):r||e)})),t}));function J(e){if("string"==typeof e||re(e))return e;var r=e+"";return"0"==r&&1/e==-p?"-0":r}function K(e,r){if("function"!=typeof e||r&&"function"!=typeof r)throw new TypeError(f);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 i=e.apply(this,n);return t.cache=u.set(o,i),i};return t.cache=new(K.Cache||B),t}K.Cache=B;var Y=Array.isArray;function ee(e){var t=r(e);return!!e&&("object"==t||"function"==t)}function re(e){return"symbol"==r(e)||function(e){return!!e&&"object"==r(e)}(e)&&M.call(e)==m}var te=function(e,r,t){var n=null==e?void 0:Z(e,r);return void 0===n?t:n},ne=function(){return{type:"",succeeded:!0,message:""}},oe=function(){return{succeeded:!0,recordErrors:{}}},ue=function(){return{succeeded:!0,fieldErrors:{},recordErrors:{}}},ie=function(e){return function(r){var t=e?e(r):{type:"",succeeded:!0,message:""};return c(t)?t:Promise.resolve(t)}},ae=function(e){return function(r){var t=e?e(r):{type:"",succeeded:!0,message:""};return c(t)?t:Promise.resolve(t)}},ce=function(e){return i(e)?{validator:ie(e),message:void 0,customArgs:void 0}:{validator:ie(e.validator),customArgs:e.customArgs,message:e.message}},se=function(e){return Array.isArray(e)?e.map(ce):[]},le=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}),{})},fe=function(e){return i(e)?{validator:ae(e),message:void 0}:{validator:ae(e.validator),message:e.message}},de=function(e){return Array.isArray(e)?e.map(fe):[]},pe=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,de(o)]}));return t.reduce((function(e,r){var t=n(r,2),o=t[0],u=t[1];return e[o]=u,e}),{})},ve=function(e,r,t,n){return e.map((function(e){return n(e,r,t)}))},he=function(e){var r=e;return e&&!a(e.succeeded)||(console.error("form-validators: One of the record validator is returning a non expected value."),r={key:"",type:"",succeeded:!0,message:""}),r},me=function(e,r){return r.validator({values:e,message:r.message}).then(he)},ye=function(e,r){return u(r)?function(e,r){return r.reduce((function(r,t){return r.then((function(r){return r.succeeded?me(e,t):r}))}),me(e,r[0]))}(e,r):Promise.resolve({key:"",type:"",succeeded:!0,message:""})},ge=function(e){var r=e;return e&&!a(e.succeeded)||(console.error("form-validators: One of the field validator is returning a non expected value."),r={key:"",type:"",succeeded:!0,message:""}),r},_e=function(e,r,t){return t.validator({value:e,values:r,customArgs:t.customArgs,message:t.message}).then(ge)},be=function(e,r,t){return u(t)?function(e,r,t){return t.reduce((function(t,n){return t.then((function(t){return t.succeeded?_e(e,r,n):t}))}),_e(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=o(r,["key"]);return e[t]=Object.assign({},n),e}),{})},we=function(e){var r={succeeded:!0,recordErrors:{}};return u(e)&&(r.succeeded=Ee(e),r.recordErrors=je(e)),r},Oe=function(e,r){return!a(r)&&!a(r[e])},Ae=function(e,r,t,n){return Oe(e,n)?be(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:""})},Pe=function(e,r){var t=ve(s(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}))},xe=function(e,r,t){var o=function(e,r,t,n){return e.map((function(e){return n(e,te(r,e,void 0),r,t)}))}(s(r),e,r,Ae),i=ve(s(t),e,t,Se);return Promise.all(o).then((function(e){return Promise.all(i).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(u(e)&&(t.succeeded=Ee(e),t.fieldErrors=je(e)),u(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}))},ke=function(){function e(r){!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(r)}var n,u,i;return n=e,(u=[{key:"setupValidationSchema",value:function(e){if(e&&"object"===r(e)){var t=e.record,n=e.field;n&&"object"===r(n)&&(this.fieldSchema=le(e.field)),t&&"object"===r(t)&&(this.recordSchema=pe(e.record))}else console.error("ValidationSchema must be a valid object")}},{key:"validateField",value:function(e,r,t){return Ae(e,r,t,this.fieldSchema).then((function(e){e.key;var r=o(e,["key"]);return Object.assign({},r)}))}},{key:"validateRecord",value:function(e){return Pe(e,this.recordSchema)}},{key:"validateForm",value:function(e){return xe(e,this.fieldSchema,this.recordSchema)}}])&&t(n.prototype,u),i&&t(n,i),e}(),Ve=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,te(r,function(e){return e.replace(/[{}]/g,"")}(t),t))}),e):e}(e,r):""},Fe="Please fill in this mandatory field.",Re={trim:!0},Te=function(e,r){return!!function(e){return null==e||""===e}(e)||r.test(e)},Me="Please enter a valid email address.",$e=/^(([^<>()\[\]\\.,;:\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,}))$/,Ne="Please provide a valid format.",Ie="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(Ie);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",Ge='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},Be="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 Fe=e},validator:function(e){var r=e.value,t=e.customArgs,n=void 0===t?Re:t,o=e.message,u=void 0===o?Fe:o,i=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:i,message:i?"":Ve(u,n),type:"REQUIRED"}}}),email:Object.freeze({__proto__:null,setErrorMessage:function(e){return Me=e},validator:function(e){var r=e.value,t=e.message,n=void 0===t?Me:t,o=function(e){return Te(e,$e)}(r);return{succeeded:o,message:o?"":n,type:"EMAIL"}}}),pattern:Object.freeze({__proto__:null,setErrorMessage:function(e){return Ne=e},validator:function(e){if(!e.customArgs)throw new Error(Ie);var r=e.value,t=e.customArgs,n=void 0===t?null:t,o=e.message,u=void 0===o?Ne:o,i=ze(n),a=Te(r,i);return{succeeded:a,message:a?"":Ve(u,n),type:"PATTERN"}}}),minLength:Object.freeze({__proto__:null,setErrorMessage:function(e){return De=e},validator:function(e){if(!e.customArgs)throw new Error(Ge);var r=e.value,t=e.customArgs,n=void 0===t?null:t,o=e.message,u=void 0===o?De:o,i=Ce(r,Le(n,Ge),Ue);return{succeeded:i,message:i?"":Ve(u,n),type:"MIN_LENGTH"}}}),maxLength:Object.freeze({__proto__:null,setErrorMessage:function(e){return Be=e},validator:function(e){if(!e.customArgs)throw new Error(He);var r=e.value,t=e.customArgs,n=void 0===t?null:t,o=e.message,u=void 0===o?Be:o,i=Ce(r,Le(n,He),Ze);return{succeeded:i,message:i?"":Ve(u,n),type:"MAX_LENGTH"}}})},Qe={validateField:Ae,validateRecord:Pe,validateForm:xe,mapToInternalFieldValidationSchema:le,mapToInternalRecordValidationSchema:pe,FormValidation:ke};e.FormValidationExtended=Qe,e.Validators=qe,e.createDefaultFormValidationResult=ue,e.createDefaultRecordValidationResult=oe,e.createDefaultValidationResult=ne,e.createFormValidation=function(e){return new ke(e)},e.parseMessageWithCustomArgs=Ve,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@lemoncode/fonk",
"version": "0.4.1",
"version": "0.4.2",
"description": "Form schema validator library",

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

]
},
"dependencies": {
"lodash.get": "^4.4.2"
}
}

@@ -0,0 +0,0 @@ # Fonk

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