UNPKG

@decaf-ts/decorator-validation

Version:
44 lines (43 loc) 1.73 kB
/** * Proxy object that provides path-based access to nested properties * @template T - The type of the target object being proxied */ export type PathProxy<T> = T & { getValueFromPath: (path: string, fallback?: any) => any; }; /** * Standard path resolution utility for accessing nested object properties. * Provides consistent dot-notation access to both parent and child properties * across complex object structures. * * - Dot-notation path resolution ('object.child.property') * - Parent traversal using '../' notation * - Configurable property access behavior * - Null/undefined safety checks */ export declare class PathProxyEngine { /** * Creates a path-aware proxy for the target object * @template T - The type of the target object * @param {T} rootTarget - The target object to proxy * @param opts - Configuration options * @param opts.getValue - Custom function to get property value * @param opts.getParent - Custom function to get parent object * @param opts.ignoreUndefined - Whether to ignore undefined values in paths * @param opts.ignoreNull - Whether to ignore null values in paths * @returns A proxy object with path access capabilities */ static create<T extends object>(rootTarget: T, opts?: { getValue?: (target: T, prop: string) => any; getParent?: (target: T) => any; ignoreUndefined: boolean; ignoreNull: boolean; }): PathProxy<T>; /** * Parses a path string into individual components * @param path - The path string to parse (e.g., "user.address.city") * @returns An array of path components * @throws Error if the path is invalid */ private static parsePath; }