UNPKG

@modular-forms/qwik

Version:

The modular and type-safe form library for Qwik

17 lines (16 loc) 626 B
import { getFieldStore } from '../utils'; export function getValue(form, name, { shouldActive = true, shouldTouched = false, shouldDirty = false, shouldValid = false, } = {}) { // Get store of specified field const field = getFieldStore(form, name); // Continue if field corresponds to filter options if (field && (!shouldActive || field.active) && (!shouldTouched || field.touched) && (!shouldDirty || field.dirty) && (!shouldValid || !field.error)) { // Return value of field return field.value; } // Otherwise return undefined return undefined; }