UNPKG

@modular-forms/solid

Version:

The modular and type-safe form library for SolidJS

21 lines (20 loc) 596 B
import { untrack } from 'solid-js'; import { removeInvalidNames } from './removeInvalidNames'; /** * Returns a list with the names of all fields. * * @param form The form of the fields. * @param shouldValid Whether to be valid. * * @returns All field names of the form. */ export function getFieldNames(form, shouldValid = true) { // Get name of every field const fieldNames = [...untrack(form.internal.fieldNames.get)]; // Remove invalid field names if (shouldValid) { removeInvalidNames(form, fieldNames); } // Return field names return fieldNames; }