1 | var appendErrors = (name, validateAllFieldCriteria, errors, type, message) => validateAllFieldCriteria
|
2 | ? {
|
3 | ...errors[name],
|
4 | types: {
|
5 | ...(errors[name] && errors[name].types ? errors[name].types : {}),
|
6 | [type]: message || true,
|
7 | },
|
8 | }
|
9 | : {};
|
10 |
|
11 | var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
|
12 |
|
13 | var isNullOrUndefined = (value) => value == null;
|
14 |
|
15 | var isDateObject = (value) => value instanceof Date;
|
16 |
|
17 | const isObjectType = (value) => typeof value === 'object';
|
18 | var isObject = (value) => !isNullOrUndefined(value) &&
|
19 | !Array.isArray(value) &&
|
20 | isObjectType(value) &&
|
21 | !isDateObject(value);
|
22 |
|
23 | var isUndefined = (val) => val === undefined;
|
24 |
|
25 | var get = (object, path, defaultValue) => {
|
26 | if (!path || !isObject(object)) {
|
27 | return defaultValue;
|
28 | }
|
29 | const result = compact(path.split(/[,[\].]+?/)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], object);
|
30 | return isUndefined(result) || result === object
|
31 | ? isUndefined(object[path])
|
32 | ? defaultValue
|
33 | : object[path]
|
34 | : result;
|
35 | };
|
36 |
|
37 | var isKey = (value) => /^\w*$/.test(value);
|
38 |
|
39 | var stringToPath = (input) => compact(input.replace(/["|']|\]/g, '').split(/\.|\[/));
|
40 |
|
41 | var set = (object, path, value) => {
|
42 | let index = -1;
|
43 | const tempPath = isKey(path) ? [path] : stringToPath(path);
|
44 | const length = tempPath.length;
|
45 | const lastIndex = length - 1;
|
46 | while (++index < length) {
|
47 | const key = tempPath[index];
|
48 | let newValue = value;
|
49 | if (index !== lastIndex) {
|
50 | const objValue = object[key];
|
51 | newValue =
|
52 | isObject(objValue) || Array.isArray(objValue)
|
53 | ? objValue
|
54 | : !isNaN(+tempPath[index + 1])
|
55 | ? []
|
56 | : {};
|
57 | }
|
58 | if (key === '__proto__') {
|
59 | return;
|
60 | }
|
61 | object[key] = newValue;
|
62 | object = object[key];
|
63 | }
|
64 | return object;
|
65 | };
|
66 |
|
67 | export { appendErrors, get, set };
|
68 | //# sourceMappingURL=react-server.esm.mjs.map
|