All files / react-app/src/formSchemas withdraw-package.ts

100% Statements 5/5
80% Branches 4/5
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27      21x         5x       4x             4x       21x      
import { events } from "shared-types/events";
import { z } from "zod";
 
export const formSchema = events["withdraw-package"].baseSchema
  .extend({
    attachments: events["withdraw-package"].attachmentsDefault,
  })
  .superRefine((data, ctx) => {
    if (
      !data.attachments.supportingDocumentation?.files.length &&
      (data.additionalInformation === undefined || data.additionalInformation === "")
    ) {
      ctx.addIssue({
        message: "An Attachment or Additional Information is required.",
        code: z.ZodIssueCode.custom,
        fatal: true,
      });
      // Zod says this is to appease types
      // https://github.com/colinhacks/zod?tab=readme-ov-file#type-refinements
      return z.NEVER;
    }
  });
 
export const formSchemaChip = events["withdraw-package"].baseSchema.extend({
  attachments: events["withdraw-package"].attachmentsChip,
});