@modular-forms/qwik
Version:
The modular and type-safe form library for Qwik
20 lines (19 loc) • 612 B
JavaScript
import { removeInvalidNames } from './removeInvalidNames';
/**
* Returns a list with the names of all field arrays.
*
* @param form The form of the field arrays.
* @param shouldValid Whether to be valid.
*
* @returns All field array names of the form.
*/
export function getFieldArrayNames(form, shouldValid = true) {
// Get name of every field array
const fieldArrayNames = Object.keys(form.internal.fieldArrays);
// Remove invalid field array names
if (shouldValid) {
removeInvalidNames(form, fieldArrayNames);
}
// Return field array names
return fieldArrayNames;
}