Oxform

Core

Public form, field, array, options, and effect APIs.

Oxform Core

@oxform/core exposes forms independently of a UI framework. Its values, status, validation, reset, and array contracts also apply to React and Solid bindings.

Form

createForm(options) and new FormApi(options)

Create a form from a Standard Schema validator and matching initial values. createForm infers issue levels from checks keys; direct class construction permits explicit value and level generics.

import { ,  } from '@oxform/core';
import {  } from 'zod';

const  = ({
  : .({ : .(), : .(.()) }),
  : { : '', : ['alpha'] },
});
const  = ();

..('email', 'ada@example.com');
..('tags', 'beta');

Direct constructors expose the same core APIs. Supply class generics when you need precise value types; the factories infer them from the schema and field path.

import { , ,  } from '@oxform/core';
import {  } from 'zod';

const  = .({ : .(), : .(.()) });
const  = new <.<typeof >>({
  ,
  : { : '', : [] },
});
const  = new <string>({ , : 'email' });
const  = new <string[]>({ , : 'tags' });

.('ada@example.com');
.('customer');

formOptions(options)

Returns the supplied configuration, preserving inferred value and issue-level types. It does not create form state or run validation. Both @oxform/react and @oxform/solid re-export it.

Properties and Methods

MemberContract
idSupplied or generated identifier.
optionsCurrent configuration.
valuesCurrent values snapshot.
statusCurrent aggregate form status.
storeRead-only observable store with values, field state, and form status.
fieldPath-based field operations listed below.
arrayPath-based array operations listed below.
validate(fields?, options?)Returns a promise of run validity and emitted issue buckets.
submit(onSuccess, onError?)Returns an async zero-argument submit handler.
reset(options?)Restores values, field state, and form status with optional preservation.
'~mount'()Returns cleanup for adapter lifecycle integration.
'~update'(options)Updates configuration without resetting current values.

The form reference describes each option, reset flag, and submit transition. The validation guide covers events, field scopes, replacement, and asynchronous results. Core reads are snapshots; subscribe through store.subscribe or createEffect to observe changes.

Field

createField({ form, name }) and new FieldApi(options)

Return an API bound to one path. Prefer the factory for path-to-value and issue-level inference.

import { ,  } from '@oxform/core';
import {  } from 'zod';

const  = ({ : .({ : .() }), : { : '' } });
const  = ({ , : 'email' });

.( => .());
.({ : { : false } });
.();
.();
.();
.({ : [{ : 'error', : { : 'Already registered' } }] });
.();

The bound API exposes options, id, value, state, and store properties. Its methods are get, change, focus, blur, register, unregister, issues, setIssues, and reset. It exposes '~mount' and '~update' for adapters. It does not expose framework input props.

form.field

MethodUsage
get(name)Read the schema-derived value at a path.
status(name)Read path-specific field status.
change(name, valueOrUpdater, options?)Write a direct value or updater result.
focus(name, options?)Focus the registered element and mark touched.
blur(name, options?)Blur the element and mark blurred.
register(name)(element)Register an element; null is a no-op.
unregister(name)Clear its reference.
issues(name, options?)Read issues, optionally including descendants.
setIssues(name, issues, options?)Replace, append, or keep issue buckets.
reset(name, options?)Restore the field value and default field state.

Bound methods have the same behavior with the name argument omitted. For status use field.state.status; for registration call field.register(element). See the field reference for change flags, issue modes, and reset limitations.

Array Field

createArrayField({ form, name }) and new ArrayFieldApi(options)

Return an API bound to an array-valued path. The factory infers its array value, item value, and issue levels.

import { ,  } from '@oxform/core';
import {  } from 'zod';

const  = ({ : .({ : .(.()) }), : { : ['alpha'] } });
const  = ({ , : 'tags' });

.('beta');
.('first');
.(1, 'middle');
.(0, 1);
.(0, 2);
.(0,  => .());
.(0);
.(['alpha']);
.();
.;

Properties are options, store, state, and ids. It also exposes '~mount' and '~update'. Read array values with get() or state.value; there is no value shortcut.

form.array exposes the same mutations with the path as the first argument, for example form.array.insert('tags', 0, 'alpha'). Read values through form.field.get('tags'). See the array reference for item identity, index normalization, updater behavior, and validation exceptions.

Effect

createEffect(api, selector, callback)

Observes selected form, field, or array state. It skips the initial value and invokes the callback only when the selection changes by deep equality. Returns a subscription with unsubscribe(). Async callbacks may overlap.

import { ,  } from '@oxform/core';
import {  } from 'zod';

const  = ({ : .({ : .() }), : { : '' } });
const  = (
  ,
   => ..,
   => {
    .();
  },
);

..('email', 'ada@example.com');
.();

Public Types

GroupTypes
Form contractsFormOptions, FormStore, FormStatus, FormWithOptions, FormSubmitSuccessHandler, FormSubmitErrorHandler.
Field contractsFieldOptions, FieldState, FieldStore, FieldStatus, FieldChangeOptions, FieldFocusOptions, FieldBlurOptions.
Array contractsArrayFieldOptions, ArrayFieldStore, ArrayLike.
Validation and issuesStandardSchema, ValidationType, ValidateOptions, FormChecksMap, FormCheckValidator, FormIssue, FormIssueEntry, FormIssueLevel, FormErrorIssueLevel, FormIssuesByLevel, FormIssuesByLevelInput, FormIssuesOptions, FormSetIssuesOptions, FieldSetIssuesMode.
Reset contractsFormResetOptions, FormResetKeepOptions, FormResetFieldOptions, FieldResetKeepOptions, FieldResetStatus.
Inference and selectorsAnyFormApi, AnyFormLikeApi, ApiSelector, FormLikeStore, FormValues, FormFields, FormArrayFields, FormFieldValue, FormIssueLevels, InferFormIssueLevels.
Additional contractsEventLike, FieldExtra, FieldPlugin, FieldPluginsInput. Plugin types are exported, but current field options do not accept plugins.
Path helpersDeepKeys, DeepValue, DeepKeysOfType, DeepRecord, DeepKeysAndValues, ArrayDeepKeys, FieldsMap, and additional exported path type helpers.

See TypeScript for schema-derived paths and values. React re-exports many core types, but the core class constructors and factories are runtime imports from @oxform/core.

Signatures

Prop

Type

Prop

Type

Prop

Type