Files
oranguru/src/Form/utils/getNestedValue.ts
2026-01-12 23:20:34 +02:00

10 lines
389 B
TypeScript

/**
* Retrieves a nested value from an object using dot notation path
* @param path - Dot-separated path (e.g., "user.address.city")
* @param obj - Object to extract value from
* @returns The value at the specified path, or undefined if not found
*/
export const getNestedValue = (path: string, obj: any): any => {
return path.split('.').reduce((prev, curr) => prev?.[curr], obj)
}