ENGLISH·COURSE API
    Preparing search index...
    • Values, validation and translated field errors for one account form.

      Type Parameters

      • Schema extends ZodObject<$ZodLooseShape, $strip>
      • Values extends Record<string, string>

      Parameters

      • schema: Schema

        The form's schema, from account-form-schemas

      • initialValues: Values

        Every field, empty

      Returns {
          values: Values;
          field: (name: keyof Values & string) => AccountFieldBinding;
          validate: () => boolean;
          reset: () => void;
      }

      The current values, a binding per field, validate and reset

      Errors appear only after validate() — a learner is not told a field is wrong while still typing into it for the first time.

      reset() returns the form to those same initial values and clears the errors — what a form that succeeded and stays on the page needs, so the learner is not left looking at the password they just replaced.

      const form = useAccountForm(signInSchema, { email: "", password: "" });
      <AccountField {...form.field("email")} label={t("fields.email")} />