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,SAACyC,GAAD,OAAgBA,GAAuD,IAA1CA,EAAUrB,QAAQ,QAAS,IAAIlB,UAEhEmC,UAAW1C,EAAAA,OAEbmH,aAAcnH,EAAAA,KAAagC,KAAK,eAAgB,CAC9CM,GAAI,UACJE,KAAMxC,EAAAA,KAEHyC,SAAS,+DACZC,UAAW1C,EAAAA,SAIFoH,EACXvF,EAAyBwF,OAAOzD,GAErB0D,EAAaxB,EAAkBuB,OAAOD,GAEtCG,EAAoBV,EAAyBQ,OACxDD,GA4DWzH,EAAoB,EAAH,SAzDiB,CAC7CoC,eAAgB,CACdM,iBAAkB,GAClBM,YAAa,IAEfM,eAAgB,GAChBhB,UAAW,GACXiB,WAAY,GACZC,wBAAyB,GACzBC,aAAc,GACdE,sBAAuB,WACvBC,YAAa,GACbC,WAAY,GACZC,UAAW,MACXC,UAAW,GACXC,WAAY,QAG0B,CACtCE,MAAO,GACPC,SAAU,GACVI,QAAS,GACTE,aAAc,GACdG,YAAa,GACbI,aAAc,GACdM,iBAAkB,GAClBC,oBAAqB,GACrBC,aAAc,GACdE,aAAc,GACdC,KAAM,GACNE,WAAY,GACZC,QAAS,iBACTI,iBAAkB,OAGoB,CACtCG,eAAgB,GAChBD,kBAAmB,GACnBE,SAAS,EACTC,eAAgB,GAChBE,oBAAqB,GACrBE,wBAAyB,GACzBC,2BAA4B,GAC5BC,oBAAqB,GACrBC,oBAAqB,GACrBC,YAAa,GACbC,kBAAmB,GACnBC,eAAgB,mBAG6B,CAC7CE,YAAa,GACbC,cAAe,GACfE,SAAU,GACVE,aAAc","sources":["webpack://_N_E/./components/ProgressBar.tsx","webpack://_N_E/./contexts/DonationContext.tsx","webpack://_N_E/./contexts/FormNameContext.tsx","webpack://_N_E/./helpers/yupMethods.ts","webpack://_N_E/./schema/single-donation.ts"],"sourcesContent":["import React, { ReactElement } from \"react\";\nimport { Step } from \"@cruk/cruk-react-components\";\nimport styled from \"styled-components\";\n\ntype ProgressBarProps = {\n steps: string[];\n current: number;\n};\n\nconst MaxWidthContainer = styled.div`\n text-align: center;\n text-transform: capitalize;\n max-width: ${({ theme }) => theme.utilities.contentMaxWidth};\n margin: ${({ theme }) => theme.spacing.m} auto 0;\n padding: 0 ${({ theme }) => theme.spacing.s};\n`;\n\nconst StepContainer = styled.div`\n margin: 0 auto;\n\n @media (min-width: ${({ theme }) => theme.breakpoint.tablet}) {\n max-width: 70%;\n }\n`;\n\nconst ProgressBar = ({ steps, current }: ProgressBarProps): ReactElement => (\n \n \n \n \n \n);\n\nexport default ProgressBar;\n","import { createContext, Dispatch, SetStateAction } from \"react\";\nimport { initialFormValues, FormSchemaType } from \"../schema/single-donation\";\n\nconst initialValue: {\n donationData: FormSchemaType;\n setDonationData: Dispatch>;\n} = {\n donationData: initialFormValues,\n setDonationData() {},\n};\n\nconst DonationContext = createContext(initialValue);\n\nexport default DonationContext;\n","import { createContext } from \"react\";\n\nconst FormNameContext = createContext(\"\");\n\nexport default FormNameContext;\n","import * as yup from \"yup\";\n\nexport const minMax = yup.addMethod(\n yup.string,\n \"minMax\",\n function (message: string, min: number, max: number) {\n return this.test(\"minMax\", message, (value): boolean => {\n if (value) {\n return value.length >= min && value.length <= max;\n }\n return true;\n });\n }\n);\n\nexport const negativeMatch = yup.addMethod(\n yup.string,\n \"negativeMatch\",\n function (message: string, regex: RegExp) {\n return this.test(\"negativeMatch\", message, (value): boolean => {\n if (value) {\n return !regex.test(value);\n }\n return false;\n });\n }\n);\n\nexport const notOnlyNum = yup.addMethod(\n yup.string,\n \"notOnlyNum\",\n function (message: string) {\n return this.test(\n \"notOnlyNum\",\n message,\n (value): boolean => !value || Number.isNaN(Number(value))\n );\n }\n);\n\nexport const addressFieldEdgeCase = yup.addMethod(\n yup.string,\n \"addressFieldEdgeCase\",\n function (message: string, regex: RegExp, field: string, field2: string) {\n // address line 1 matches address line 2\n return this.test(\"addressFieldEdgeCase\", message, (value: any): boolean => {\n const addressField = document.getElementsByName(\n field\n )[0] as HTMLInputElement;\n const addressField2 = document.getElementsByName(\n field2\n )[0] as HTMLInputElement;\n if (\n regex.test(value) &&\n addressField?.value === \"\" &&\n addressField2?.value === \"\"\n ) {\n return false;\n }\n return true;\n });\n }\n);\n\nexport const equalsOtherField = yup.addMethod(\n yup.string,\n \"equalsOtherField\",\n function (message: string, field: string) {\n return this.test(\"equalsOtherField\", message, (value: any): boolean => {\n const comparisonField = document.getElementsByName(\n field\n )[0] as HTMLInputElement;\n if (comparisonField && value) {\n return (\n comparisonField.value.trim().toLowerCase() !==\n value.trim().toLowerCase()\n );\n }\n return true;\n });\n }\n);\n\nexport const firstDigitCheck = yup.addMethod(\n yup.string,\n \"firstDigitCheck\",\n function (message: string) {\n return this.test(\"firstDigitCheck\", message, (value: any): boolean => {\n if (value) {\n const firstTwoNumbers = value.substring(0, 2);\n return message.includes(\"mobile\")\n ? firstTwoNumbers === \"07\"\n : firstTwoNumbers === \"01\" ||\n firstTwoNumbers === \"02\" ||\n firstTwoNumbers === \"07\";\n }\n return true;\n });\n }\n);\n\nexport const ukOnlyMobileNumber = yup.addMethod(\n yup.string,\n \"ukOnlyMobileNumber\",\n function (message: string) {\n const disallowedPrefixes = [\n \"07797\",\n \"07624\",\n \"07524\",\n \"07924\",\n \"07781\",\n \"07839\",\n \"07911\",\n \"07509\",\n \"07937\",\n \"07700\",\n \"07829\",\n ];\n return this.test(\"ukOnlyMobileNumber\", message, (value: any): boolean => {\n if (value) {\n const trimmedVal = value.trim().replace(/\\s/g, \"\");\n if (trimmedVal.substring(0, 2) === \"07\") {\n const firstFiveNumbers = trimmedVal.substring(0, 5);\n if (disallowedPrefixes.includes(firstFiveNumbers)) {\n return false;\n }\n return true;\n }\n return false;\n }\n return true;\n });\n }\n);\n","import * as yup from \"yup\";\nimport { isUkCountry } from \"../helpers/functions/shared\";\nimport {\n addressLine1RegExp,\n addressLine23RegExp,\n amountRegExp,\n andRegExp,\n cityRegExp,\n extraEmailRegExp,\n nameRegExp,\n nameExcludedRegExp,\n postcodeIntlRegExp,\n postcodeUkRegExp,\n singleCharRegExp,\n phoneRegExp,\n numbersOnlyRegExp,\n sortCodeRegExp,\n} from \"../helpers/regexp\";\nimport { Option } from \"../helpers/types/shared\";\nimport \"../helpers/yupMethods\";\n\nconst getRequiredMessage = (hasNudges: boolean) =>\n `Please ${\n hasNudges ? \"select or \" : \"\"\n }type in the amount you'd like to donate.`;\n\nconst donationAmountSchema = (\n frequency: Option,\n formVersion: string\n) => {\n let max: number;\n\n switch (frequency) {\n case \"Monthly\":\n max = 850;\n break;\n case \"Quarterly\":\n max = 2500;\n break;\n case \"Annually\":\n max = 10000;\n break;\n default:\n max = 100000;\n }\n\n const base = {\n amountRadioGroup: yup.mixed().when(\"otherAmount\", {\n is: \"\" || undefined,\n then: yup\n .string()\n .when(\"$hasNudges\", (hasNudges: boolean, schema) =>\n schema.required(getRequiredMessage(hasNudges))\n ),\n otherwise: yup.string(),\n }),\n otherAmount: yup.mixed().when(\"amountRadioGroup\", {\n is: \"\" || undefined,\n then: yup\n .string()\n .matches(\n amountRegExp,\n \"Please enter an amount using numbers and a decimal point only.\"\n )\n .test(\n \"min\",\n \"Please enter an amount of £2 or greater.\",\n (userInput) => !userInput || Number(userInput) >= 2\n )\n .test(\n \"max\",\n formVersion === \"regular\"\n ? \"Thank you for your generous donation. So that we’re able to thank you appropriately, please call our Supporter Services team on 0300 123 6646 to complete the transaction.\"\n : \"We only accept donations up to £100,000 online. To donate a different amount call us on 0300 123 1022.\",\n (userInput) =>\n (typeof frequency === \"undefined\" && formVersion === \"regular\") ||\n !userInput ||\n Number(userInput) <= max\n )\n .when(\"$hasNudges\", (hasNudges: boolean, schema) =>\n schema.required(getRequiredMessage(hasNudges))\n ),\n otherwise: yup.string(),\n }),\n };\n\n return {\n fields: base,\n noSortEdges: [\"amountRadioGroup\", \"otherAmount\"],\n };\n};\n\nexport const DonationAmountFormSchema = yup.object().shape({\n donationAmount: yup\n .object()\n // @ts-ignore\n .when([\"frequency\", \"$formVersion\"], (frequency, formVersion, schema) => {\n const { fields, noSortEdges } = donationAmountSchema(\n frequency,\n formVersion\n );\n return schema.shape(fields, noSortEdges);\n }),\n frequency: yup.string().when(\"$formVersion\", {\n is: \"regular\",\n then: yup\n .string()\n .required(\"Please select how often you'd like to make your donation.\"),\n otherwise: yup.string(),\n }),\n typeRadioGroup: yup.string().when(\"$formVersion\", {\n is: \"single\",\n then: yup.string().required(\"Please select an option to continue.\"),\n otherwise: yup.string(),\n }),\n motivation: yup.string(),\n otherDonationMotivation: yup\n .string()\n .trim()\n .max(100, \"Please complete with a maximum of 100 characters.\"),\n inMemoryName: yup\n .string()\n .trim()\n .matches(nameRegExp, {\n message: \"Please only use letters and hyphens.\",\n })\n .max(100, \"Please complete with a maximum of 100 characters.\"),\n destinationRadioGroup: yup\n .string()\n .required(\"Please select an option to continue\"),\n restriction: yup.string(),\n emailOptIn: yup.string(),\n postOptIn: yup.string(),\n textOptIn: yup.string(),\n phoneOptIn: yup.string(),\n});\n\nexport const DetailsFormSchema = yup.object().shape({\n title: yup.string(),\n forename: yup\n .string()\n .trim()\n .required(\"Please enter your first name.\")\n .max(\n 50,\n \"Please enter your first name, over 50 characters is not accepted.\"\n )\n .matches(nameRegExp, {\n message: \"Please only use letters and hyphens.\",\n })\n // @ts-expect-error\n .negativeMatch(\n \"Please enter your first name, this cannot contain the word 'and'.\",\n andRegExp\n )\n .negativeMatch(\"Please enter a valid first name.\", nameExcludedRegExp),\n surname: yup\n .string()\n .trim()\n .required(\"Please enter your last name.\")\n .matches(nameRegExp, {\n message: \"Please only use letters and hyphens.\",\n })\n // @ts-expect-error\n .minMax(\"Please enter your last name between 2 - 50 characters.\", 2, 50)\n .negativeMatch(\n \"Please enter your last name, this cannot contain the word 'and'.\",\n andRegExp\n )\n .negativeMatch(\"Please enter a valid last name.\", nameExcludedRegExp),\n emailAddress: yup\n .string()\n .trim()\n .email(\"Please enter a valid email address.\")\n .required(\"Please enter a valid email address.\")\n // @ts-expect-error\n .negativeMatch(\"Please enter a valid email address.\", extraEmailRegExp)\n .max(\n 100,\n \"Please enter your email address. Over 100 characters is not accepted.\"\n ),\n phoneNumber: yup\n .string()\n .trim()\n .matches(phoneRegExp, {\n message: \"Please enter a valid phone number so we can contact you.\",\n excludeEmptyString: true,\n })\n .when([\"textOptIn\", \"phoneOptIn\"], {\n is: (textOptIn: string, phoneOptIn: string) =>\n phoneOptIn === \"yes\" || textOptIn === \"yes\",\n then: (schema) =>\n schema.when([\"$formVersion\", \"$formName\"], {\n is: (formVersion: string, formName: string) =>\n formVersion === \"single\" && formName === \"support-us\",\n then: yup\n .string()\n .required(\n 'Phone number is required because staying in touch by phone or text message is set to \"Yes\".'\n ),\n otherwise: yup\n .string()\n .required(\n \"Please enter a valid phone number so we can contact you.\"\n ),\n }),\n otherwise: (schema) => schema,\n }),\n addressLine1: yup\n .string()\n .trim()\n .required(\"Please complete address line 1.\")\n .matches(addressLine1RegExp, {\n message: \"Please only use letters, numbers and the following: - ' / . ,\",\n })\n .test(\n \"mimax\",\n \"Please enter address line 1 between 2 - 200 characters.\",\n (userInput) =>\n !userInput ||\n (!(userInput.replace(/[, ]/g, \"\").length < 2) &&\n !(userInput.replace(/[, ]/g, \"\").length > 200))\n )\n // @ts-expect-error\n .notOnlyNum(\n \"Please complete address line 1 including your house number and street name.\"\n )\n .equalsOtherField(\"Town name should not appear in address line 1.\", \"city\")\n .addressFieldEdgeCase(\n \"Please enter address line 1 between 2 - 200 characters.\",\n singleCharRegExp,\n \"addressLine2\",\n \"addressLine3\"\n ),\n addressSelection: yup.string().when(\"addressSearchStatus\", {\n is: \"search\",\n then: yup.string().required(\"Please select an address.\"),\n }),\n addressSearchStatus: yup.string(),\n addressLine2: yup\n .string()\n .trim()\n .matches(addressLine23RegExp, {\n message: \"Please only use letters, numbers and the following: - ' / . ,\",\n excludeEmptyString: true,\n })\n .max(\n 100,\n \"Please enter address line 2. Over 100 characters is not accepted.\"\n )\n // @ts-expect-error\n .equalsOtherField(\"Town name should not appear in address line 2.\", \"city\"),\n addressLine3: yup\n .string()\n .trim()\n .matches(addressLine23RegExp, {\n message: \"Please only use letters, numbers and the following: - ' / . ,\",\n excludeEmptyString: true,\n })\n .max(\n 100,\n \"Please enter address line 3. Over 100 characters is not accepted.\"\n )\n // @ts-expect-error\n .equalsOtherField(\"Town name should not appear in address line 3.\", \"city\"),\n city: yup\n .string()\n .trim()\n .required(\"Please enter your town or city.\")\n .matches(cityRegExp, {\n message: \"Please only use letters and the following: - ' / .\",\n })\n .max(\n 50,\n \"Please enter your town or city. Over 50 characters is not accepted.\"\n ),\n postalCode: yup\n .string()\n .trim()\n .required(\"Please enter a valid postcode.\")\n // @ts-expect-error\n .minMax(\"Please enter a postcode between 2 - 8 characters.\", 2, 8)\n .when(\"country\", {\n is: (country: string) => isUkCountry(country),\n then: yup.string().trim().matches(postcodeUkRegExp, {\n message: \"Please enter a valid postcode.\",\n }),\n otherwise: yup.string().trim().matches(postcodeIntlRegExp, {\n message: \"Please enter a valid postcode.\",\n }),\n }),\n country: yup.string().required(),\n validationStatus: yup.string().required(),\n});\n\nexport const PaymentFormSchema = yup.object().shape({\n paymentRadioGroup: yup.string().when(\"$formVersion\", {\n is: \"single\",\n then: yup.string().required(\"Please select a payment method to continue.\"),\n otherwise: yup.string(),\n }),\n cardholderName: yup.string().when([\"$formVersion\", \"paymentRadioGroup\"], {\n is: (formVersion: string, paymentRadioGroup: string) =>\n formVersion === \"single\" && paymentRadioGroup === \"bt\",\n then: yup\n .string()\n .trim()\n .required(\n \"Please enter the name of the cardholder as it appears on the card.\"\n )\n // @ts-expect-error\n .minMax(\n \"Please enter your cardholder name between 2 - 175 characters.\",\n 2,\n 175\n )\n .matches(nameRegExp, {\n message: \"Please only use letters and hyphens.\",\n })\n .negativeMatch(\n \"Please enter your cardholder name, this cannot contain the word 'and'.\",\n andRegExp\n )\n .negativeMatch(\n \"Please enter a valid cardholder name.\",\n nameExcludedRegExp\n ),\n otherwise: yup.string(),\n }),\n giftAid: yup.boolean(),\n billingAddress: yup.array().nullable(),\n billingAddressLine1: yup.string().when(\"billingAddress\", {\n is: (val: string) => val && val.includes(\"yes\"),\n then: yup\n .string()\n .trim()\n .required(\"Please complete address line 1.\")\n .test(\n \"mimax\",\n \"Please enter address line 1 between 2 - 200 characters.\",\n (userInput) =>\n !userInput ||\n (!(userInput.replace(/[, ]/g, \"\").length < 2) &&\n !(userInput.replace(/[, ]/g, \"\").length > 200))\n )\n .matches(addressLine1RegExp, {\n message:\n \"Please only use letters, numbers and the following: - ' / . ,\",\n excludeEmptyString: true,\n })\n // @ts-expect-error\n .notOnlyNum(\n \"Please complete address line 1 including your house number and street name.\"\n )\n .equalsOtherField(\n \"Town name should not appear in address line 1.\",\n \"billingCity\"\n )\n .addressFieldEdgeCase(\n \"Please enter address line 1 between 2 - 200 characters.\",\n singleCharRegExp,\n \"billingAddressLine2\",\n \"billingAddressLine3\"\n ),\n otherwise: yup.string(),\n }),\n billingAddressSelection: yup.string().when(\"billingAddressSearchStatus\", {\n is: \"search\",\n then: yup.string().required(\"Please select an address.\"),\n }),\n billingAddressSearchStatus: yup.string(),\n billingAddressLine2: yup\n .string()\n .trim()\n .matches(addressLine23RegExp, {\n message: \"Please only use letters, numbers and the following: - ' / . ,\",\n excludeEmptyString: true,\n })\n .max(\n 100,\n \"Please enter address line 2. Over 100 characters is not accepted.\"\n )\n // @ts-expect-error\n .equalsOtherField(\n \"Town name should not appear in address line 2.\",\n \"billingCity\"\n ),\n billingAddressLine3: yup\n .string()\n .trim()\n .matches(addressLine23RegExp, {\n message: \"Please only use letters, numbers and the following: - ' / . ,\",\n excludeEmptyString: true,\n })\n .max(\n 100,\n \"Please enter address line 3. Over 100 characters is not accepted.\"\n )\n // @ts-expect-error\n .equalsOtherField(\n \"Town name should not appear in address line 3.\",\n \"billingCity\"\n ),\n billingCity: yup.string().when(\"billingAddress\", {\n is: (val: string) => val && val.includes(\"yes\"),\n then: yup\n .string()\n .trim()\n .required(\"Please enter your town or city.\")\n .max(\n 50,\n \"Please enter your town or city. Over 50 characters is not accepted.\"\n )\n .matches(cityRegExp, {\n message: \"Please only use letters and the following: - ' / .\",\n }),\n otherwise: yup.string(),\n }),\n billingPostalCode: yup\n .string()\n .trim()\n // @ts-expect-error\n .minMax(\"Please enter a postcode between 2 - 8 characters.\", 2, 8)\n .when(\"billingAddress\", {\n is: (val: string) => val && val.includes(\"yes\"),\n then: yup\n .string()\n .required(\"Please enter a valid postcode.\")\n .when(\"billingCountry\", {\n is: (val: string) => isUkCountry(val),\n then: yup.string().trim().matches(postcodeUkRegExp, {\n message: \"Please enter a valid postcode.\",\n }),\n otherwise: yup.string().trim().matches(postcodeIntlRegExp, {\n message: \"Please enter a valid postcode.\",\n }),\n }),\n }),\n billingCountry: yup.string(),\n});\n\nexport const RegularPaymentFormSchema = yup.object().shape({\n accountName: yup.string().when(\"$formVersion\", {\n is: \"regular\",\n then: yup\n .string()\n .required(\"Please enter the account holder's name.\")\n // @ts-expect-error\n .minMax(\n \"Please enter the account holder's name between 2 - 50 characters.\",\n 2,\n 50\n )\n .matches(nameRegExp, {\n message: \"Please only use letters and hyphens.\",\n }),\n otherwise: yup.string(),\n }),\n accountNumber: yup.string().when(\"$formVersion\", {\n is: \"regular\",\n then: yup\n .string()\n .required(\"Please enter your account number.\")\n .matches(numbersOnlyRegExp, {\n message: \"Please enter a valid account number.\",\n })\n .length(8, \"Please enter account number with 8 digits.\"),\n otherwise: yup.string(),\n }),\n sortCode: yup.string().when(\"$formVersion\", {\n is: \"regular\",\n then: yup\n .string()\n .required(\"Please enter your sort code.\")\n .matches(sortCodeRegExp, {\n message: \"Please enter a valid sort code.\",\n })\n .test(\n \"minmax\",\n \"Your sort code should have 6 digits.\",\n (userInput) => !userInput || userInput.replace(/[- ]/g, \"\").length === 6\n ),\n otherwise: yup.string(),\n }),\n donationDate: yup.string().when(\"$formVersion\", {\n is: \"regular\",\n then: yup\n .string()\n .required(\"Please select the date you'd like to make your donation on.\"),\n otherwise: yup.string(),\n }),\n});\n\nexport const DonationAndDetailFormSchema =\n DonationAmountFormSchema.concat(DetailsFormSchema);\n\nexport const FormSchema = PaymentFormSchema.concat(DonationAndDetailFormSchema);\n\nexport const RegularFormSchema = RegularPaymentFormSchema.concat(\n DonationAndDetailFormSchema\n);\n\nexport const initialDonationAmountFormValues = {\n donationAmount: {\n amountRadioGroup: \"\",\n otherAmount: \"\",\n },\n typeRadioGroup: \"\",\n frequency: \"\",\n motivation: \"\",\n otherDonationMotivation: \"\",\n inMemoryName: \"\",\n destinationRadioGroup: \"greatest\",\n restriction: \"\",\n emailOptIn: \"\",\n postOptIn: \"yes\",\n textOptIn: \"\",\n phoneOptIn: \"yes\",\n};\n\nexport const initialDetailsFormValues = {\n title: \"\",\n forename: \"\",\n surname: \"\",\n emailAddress: \"\",\n phoneNumber: \"\",\n addressLine1: \"\",\n addressSelection: \"\",\n addressSearchStatus: \"\",\n addressLine2: \"\",\n addressLine3: \"\",\n city: \"\",\n postalCode: \"\",\n country: \"United Kingdom\",\n validationStatus: \"NV\",\n};\n\nexport const initialPaymentFormValues = {\n cardholderName: \"\",\n paymentRadioGroup: \"\",\n giftAid: false,\n billingAddress: \"\",\n billingAddressLine1: \"\",\n billingAddressSelection: \"\",\n billingAddressSearchStatus: \"\",\n billingAddressLine2: \"\",\n billingAddressLine3: \"\",\n billingCity: \"\",\n billingPostalCode: \"\",\n billingCountry: \"United Kingdom\",\n};\n\nexport const initialRegularPaymentFormValues = {\n accountName: \"\",\n accountNumber: \"\",\n sortCode: \"\",\n donationDate: \"\",\n};\n\nexport const initialFormValues = {\n ...initialDonationAmountFormValues,\n ...initialDetailsFormValues,\n ...initialPaymentFormValues,\n ...initialRegularPaymentFormValues,\n};\n\nexport type FormSchemaType = typeof initialFormValues;\n"],"names":["MaxWidthContainer","styled","theme","utilities","contentMaxWidth","spacing","m","s","StepContainer","breakpoint","tablet","steps","current","initialValue","donationData","initialFormValues","setDonationData","DonationContext","createContext","FormNameContext","yup","message","min","max","this","test","value","length","regex","Number","isNaN","field","field2","addressField","document","getElementsByName","addressField2","comparisonField","trim","toLowerCase","firstTwoNumbers","substring","includes","disallowedPrefixes","trimmedVal","replace","firstFiveNumbers","getRequiredMessage","hasNudges","DonationAmountFormSchema","shape","donationAmount","when","frequency","formVersion","schema","fields","amountRadioGroup","is","undefined","then","required","otherwise","otherAmount","matches","amountRegExp","userInput","noSortEdges","donationAmountSchema","typeRadioGroup","motivation","otherDonationMotivation","inMemoryName","nameRegExp","destinationRadioGroup","restriction","emailOptIn","postOptIn","textOptIn","phoneOptIn","DetailsFormSchema","title","forename","negativeMatch","andRegExp","nameExcludedRegExp","surname","minMax","emailAddress","email","extraEmailRegExp","phoneNumber","phoneRegExp","excludeEmptyString","formName","addressLine1","addressLine1RegExp","notOnlyNum","equalsOtherField","addressFieldEdgeCase","singleCharRegExp","addressSelection","addressSearchStatus","addressLine2","addressLine23RegExp","addressLine3","city","cityRegExp","postalCode","country","isUkCountry","postcodeUkRegExp","postcodeIntlRegExp","validationStatus","PaymentFormSchema","paymentRadioGroup","cardholderName","giftAid","billingAddress","nullable","billingAddressLine1","val","billingAddressSelection","billingAddressSearchStatus","billingAddressLine2","billingAddressLine3","billingCity","billingPostalCode","billingCountry","RegularPaymentFormSchema","accountName","accountNumber","numbersOnlyRegExp","sortCode","sortCodeRegExp","donationDate","DonationAndDetailFormSchema","concat","FormSchema","RegularFormSchema"],"sourceRoot":""}