@modular-forms/solid
Version:
The modular and type-safe form library for SolidJS
16 lines (15 loc) • 653 B
JavaScript
import { initializeFieldStore } from '../utils';
export function getValue(form, name, { shouldActive = true, shouldTouched = false, shouldDirty = false, shouldValid = false, } = {}) {
// Get store of specified field
const field = initializeFieldStore(form, name);
// Continue if field corresponds to filter options
if ((!shouldActive || field.active.get()) &&
(!shouldTouched || field.touched.get()) &&
(!shouldDirty || field.dirty.get()) &&
(!shouldValid || !field.error.get())) {
// Return value of field
return field.value.get();
}
// Otherwise return undefined
return undefined;
}