UNPKG

@modular-forms/qwik

Version:

The modular and type-safe form library for Qwik

21 lines (20 loc) 834 B
import { getFieldArrayStore } from '../utils'; /** * Checks if the specified field array is included in the form. * * @param form The form of the field array. * @param name The name of the field array. * @param options The field array options. * * @returns Whether the field array is included. */ export function hasFieldArray(form, name, { shouldActive = true, shouldTouched = false, shouldDirty = false, shouldValid = false, } = {}) { // Get store of specified field array const fieldArray = getFieldArrayStore(form, name); // Return whether field array is present and matches filter options return (!!fieldArray && (!shouldActive || fieldArray.active) && (!shouldTouched || fieldArray.touched) && (!shouldDirty || fieldArray.dirty) && (!shouldValid || !fieldArray.error)); }