Hex Core JS
    Preparing search index...

    Function formStateHasField

    • Type guard to check whether the form values (of a type constructed from another with Pick and a parameterized key type) for the given form state contain the given field name. In other words, reports whether F extends TF.

      Type Parameters

      • FV extends FormValues
      • F extends string | number | symbol
      • TF extends string | number | symbol

      Parameters

      • formState: Pick<FormState<Pick<FV, F>>, "formValues">

        The form state to check.

      • fieldName: TF

        The field name to check for.

      Returns formState is FormState<Pick<FV, F | TF>>

      function setFields<K extends keyof ExampleFormValues = keyof ExampleFormValues>(formState: FormState<Pick<ExampleFormValues, K>>) {
      if (formStateHasField(formState, "name")) {
      formState.formSetFunctions.name("New Name");
      }
      }