All files / src/features/GiveOnboarding/pages/Agreement/Review schema.ts

80% Statements 4/5
37.5% Branches 3/8
75% Functions 3/4
80% Lines 4/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 28 29 30 31 32 33 34 35 36      9x               2x           2x                         2x          
import * as Yup from "yup";
import { VALIDATION_MESSAGES } from "@validation/messages";
 
export const agreementReviewSchema = Yup.object().shape({
  msaPCICompliant: Yup.boolean().oneOf([true], "PCI compliance is required"),
 
  msaRefundPolicy: Yup.string().optional(),
 
  msaPreviousTermination: Yup.boolean(),
 
  processorName: Yup.lazy((_, context) =>
    context.parent.msaPreviousTermination
      ? Yup.string().required(VALIDATION_MESSAGES.REQUIRED)
      : Yup.mixed().notRequired(),
  ),
 
  terminationDate: Yup.lazy((_, context) =>
    context.parent.msaPreviousTermination
      ? Yup.mixed()
          .nullable()
          .required(VALIDATION_MESSAGES.REQUIRED)
          .test(
            "not-empty",
            VALIDATION_MESSAGES.REQUIRED,
            (value) => value !== "" || value !== null,
          )
      : Yup.mixed().notRequired(),
  ),
 
  terminationReason: Yup.lazy((_, context) =>
    context.parent.msaPreviousTermination
      ? Yup.string().required(VALIDATION_MESSAGES.REQUIRED)
      : Yup.mixed().notRequired(),
  ),
});