Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/yup/es/util/ drwxr-xr-x | |
| Viewing file: Select action/file-type: import { forEach } from 'property-expr';
let trim = part => part.substr(0, part.length - 1).substr(1);
export function getIn(schema, path, value, context = value) {
let parent, lastPart, lastPartDebug; // root path: ''
if (!path) return {
parent,
parentPath: path,
schema
};
forEach(path, (_part, isBracket, isArray) => {
let part = isBracket ? trim(_part) : _part;
schema = schema.resolve({
context,
parent,
value
});
if (schema.innerType) {
let idx = isArray ? parseInt(part, 10) : 0;
if (value && idx >= value.length) {
throw new Error(`Yup.reach cannot resolve an array item at index: ${_part}, in the path: ${path}. ` + `because there is no value at that index. `);
}
parent = value;
value = value && value[idx];
schema = schema.innerType;
} // sometimes the array index part of a path doesn't exist: "nested.arr.child"
// in these cases the current part is the next schema and should be processed
// in this iteration. For cases where the index signature is included this
// check will fail and we'll handle the `child` part on the next iteration like normal
if (!isArray) {
if (!schema.fields || !schema.fields[part]) throw new Error(`The schema does not contain the path: ${path}. ` + `(failed at: ${lastPartDebug} which is a type: "${schema._type}")`);
parent = value;
value = value && value[part];
schema = schema.fields[part];
}
lastPart = part;
lastPartDebug = isBracket ? '[' + _part + ']' : '.' + _part;
});
return {
schema,
parent,
parentPath: lastPart
};
}
const reach = (obj, path, value, context) => getIn(obj, path, value, context).schema;
export default reach; |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.005 ]-- |