@jsvision/forms / FormFieldError
Class: FormFieldError
Defined in: errors.ts:25
Thrown when a form field cannot be resolved. Two cases raise it:
- A form's
field(name)accessor is called with a name that is not one of the schema's fields. The typed API constrainsfieldto the schema keys, so this only fires when a name is reached dynamically — through a cast or a runtime-computed string. bindField(field, view)is given a field handle that was not produced by this form'screateForm(a foreign or hand-built object). Such a handle has no registered touched seam, so binding it would silently do nothing; failing fast surfaces the mistake instead.error.fieldcarries the handle'sname.
Example
ts
import { createForm, FormFieldError } from '@jsvision/forms';
import { z } from 'zod';
const form = createForm({ schema: z.object({ name: z.string() }), initial: { name: '' } });
try {
form.field('nope' as never);
} catch (err) {
if (err instanceof FormFieldError) console.error(err.field); // 'nope'
}Extends
Error
Constructors
Constructor
new FormFieldError(
field):FormFieldError
Defined in: errors.ts:29
Parameters
field
string
Returns
FormFieldError
Overrides
Error.constructor
Properties
field
readonlyfield:string
Defined in: errors.ts:27
The field name that was requested but does not exist on the form.