easy-forms
API reference

Store

createFormStore and the FormStore interface.

import { createFormStore } from '@easy-forms/core';

const store = createFormStore({ initialValues, validationMode });

Most apps never call this — <Form> creates a store internally. Create one yourself to drive values programmatically or share state across components, then pass it to <Form store={store}>.

Options

PropTypeDefaultDescription
initialValuesRecord<string, unknown>Initial field values.
validationMode'onChange' | 'onBlur' | 'onSubmit' | 'all'When fields validate.

FormStore (selected members)

PropTypeDefaultDescription
getValue / getValues() => unknownRead a field or all values.
setValue(key, value, options?) => voidSet a value. options: { validate, touch, markDirty }.
getFieldState(key) => FieldStateRead a field's full state.
getDerived() => FormDerivedStateAggregate isDirty / isValid / values / errors.
validateField / validateAll(...) => Promise<boolean>Run validation imperatively.
resetField / reset(...) => voidReset one field or the whole form.
submit(handler) => Promise<void>Validate then invoke the handler with values.
subscribeField / subscribeForm / subscribeGroup(…, listener) => unsubscribeLow-level subscriptions (the hooks wrap these).

SetValueOptions

PropTypeDefaultDescription
validatebooleantrueValidate after setting.
touchbooleanfalseMark the field touched.
markDirtybooleantrueUpdate the dirty flag. Dependency-engine derivations use false.