dynamic-forms / Function

parseMultiArrayPath

Parses a path that may contain multiple array placeholders.

This supports deeply nested array structures like orders.$.items.$.quantity where multiple levels of arrays need to be traversed.

Presentation

function parseMultiArrayPath(path: string): MultiArrayPathInfo;

Returns

MultiArrayPathInfo -

Parsed path information

Parameters

NameTypeDescription
path
string

Path with zero or more $ placeholders

Example usage

parseMultiArrayPath('orders.$.items.$.quantity')
// {
//   isArrayPath: true,
//   placeholderCount: 2,
//   segments: ['orders', 'items', 'quantity'],
//   placeholderPositions: [1, 3]
// }

parseMultiArrayPath('items.$.name')
// {
//   isArrayPath: true,
//   placeholderCount: 1,
//   segments: ['items', 'name'],
//   placeholderPositions: [1]
// }

parseMultiArrayPath('simpleField')
// {
//   isArrayPath: false,
//   placeholderCount: 0,
//   segments: ['simpleField'],
//   placeholderPositions: []
// }