dynamic-forms / Function

extractArrayPath

Extracts the array path from a path that may contain an array placeholder.

Presentation

function extractArrayPath(path: string): string;

Returns

string -

The array path, or empty string if not an array path

Parameters

NameTypeDescription
path
string

The path to extract from

Example usage

extractArrayPath('items.$.quantity')
// 'items'

extractArrayPath('orders.lineItems.$.total')
// 'orders.lineItems'

extractArrayPath('simpleField')
// ''