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) /usr/local/lib/node_modules/strapi/node_modules/yup/es/util/ drwxr-xr-x | |
| Viewing file: Select action/file-type: import { forEach } from 'property-expr';
import has from "lodash-es/has";
var trim = function trim(part) {
return part.substr(0, part.length - 1).substr(1);
};
export function getIn(schema, path, value, context) {
var parent, lastPart, lastPartDebug; // if only one "value" arg then use it for both
context = context || value;
if (!path) return {
parent: parent,
parentPath: path,
schema: schema
};
forEach(path, function (_part, isBracket, isArray) {
var part = isBracket ? trim(_part) : _part;
if (isArray || has(schema, '_subType')) {
// we skipped an array: foo[].bar
var idx = isArray ? parseInt(part, 10) : 0;
schema = schema.resolve({
context: context,
parent: parent,
value: value
})._subType;
if (value) {
if (isArray && 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. ");
}
value = value[idx];
}
}
if (!isArray) {
schema = schema.resolve({
context: context,
parent: parent,
value: value
});
if (!has(schema, 'fields') || !has(schema.fields, part)) throw new Error("The schema does not contain the path: " + path + ". " + ("(failed at: " + lastPartDebug + " which is a type: \"" + schema._type + "\") "));
schema = schema.fields[part];
parent = value;
value = value && value[part];
lastPart = part;
lastPartDebug = isBracket ? '[' + _part + ']' : '.' + _part;
}
});
return {
schema: schema,
parent: parent,
parentPath: lastPart
};
}
var reach = function reach(obj, path, value, context) {
return getIn(obj, path, value, context).schema;
};
export default reach; |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0042 ]-- |