Evalkeeper
    Preparing search index...

    Function inputFromJson

    • A suite's inputFromForm for fixture suites (caseKind: "fixture"), whose cases are edited as JSON in one textarea. Reads the field, parses it, and checks it with the schema; throws a plain error when it's empty, isn't valid JSON ("Input isn't valid JSON: …"), or doesn't fit, naming the first part that doesn't ("Input doesn't fit at facts, item 2, name: Required").

      Type Parameters

      • T

      Parameters

      • schema: ZodType<T>

        The suite's input schema.

      • field: string = "input"

        The form field holding the JSON; default "input".

      Returns (form: FormData) => T

      A form reader to use as the suite's inputFromForm.

      const profileFit: Suite<Profile, Fit, FitLabel> = {
      // …
      caseKind: "fixture",
      inputFromForm: inputFromJson(profileSchema),
      labelFromForm: labelFromJson(fitLabelSchema),
      };