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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | 70x 70x 70x | /**
* Business Profile Validation Module
*
* Centralized validation schemas for business profile forms.
*
* @module validation/merchant/businessProfile
*/
import * as Yup from "yup";
import { createPhoneValidator } from "@validation/fields";
import { createStreetAddressValidator } from "@validation/address/streetValidator";
import { buildZipSchema } from "@validation/address/zipValidator";
import { createStateValidator } from "@validation/address/stateValidator";
import { createCountryValidator } from "@validation/address/countryValidator";
import { createCityValidation } from "@validation/address/cityValidator";
import {
TCreateMerchant,
TCreateProvider,
} from "@components/Merchants/CreateMerchantPanel/types";
/**
* Business profile schema for merchant preview/edit
* Used in merchant preview modals
*/
export const getBusinessProfileSchema = (isMerchant: boolean) =>
Yup.object().shape({
businessType: Yup.string(),
ownershipType: Yup.string(),
legalName: Yup.string().required("Business Legal Name is required"),
DBA: Yup.string(),
taxID: Yup.string().required("Tax ID is required"),
businessOpenedAt: isMerchant
? Yup.string().required("Date business opened is required")
: Yup.string(),
contactPhone: createPhoneValidator({
required: true,
requiredMessage: "Phone number is required",
invalidMessage: "Please enter a valid phone number",
}),
});
/**
* Business profile schema for create merchant/provider flow
* Used in CreateMerchantPanel
*/
export const createBusinessProfileSchema = {
isLinkBusinessProfile: Yup.boolean(),
linkedBusinessProfile: Yup.number(),
businessType: Yup.string(),
ownershipType: Yup.string(),
legalName: Yup.string(),
DBA: Yup.string(),
taxID: Yup.string(),
contactPhone: Yup.string(),
address: Yup.object({
country: createCountryValidator({ nullable: false }),
city: createCityValidation(),
address: createStreetAddressValidator({ required: false }),
state: createStateValidator(),
zip: buildZipSchema({ allowNull: false }),
}),
};
type BusinessProfile = Pick<
TCreateMerchant & TCreateProvider,
"businessProfile"
>["businessProfile"];
type BusinessProfileDefaultValues = Omit<
BusinessProfile,
| "pendingLegalEntityStatus"
| "pendingLegalEntityEmail"
| "id"
| "isController"
| "dba"
| "ageOfBusiness"
| "statusName"
| "statusDisplayName"
| "ofac"
>;
/**
* Default values for business profile form
* Used in CreateMerchantPanel and related components
*/
export const businessProfileDefaultValues: BusinessProfileDefaultValues = {
isLinkBusinessProfile: false,
businessType: "corporation",
ownershipType: "public",
legalName: "",
DBA: "",
taxID: "",
ssn: "",
tinType: "ein",
contactPhone: "",
businessOpenedAt: "",
address: {
country: "US",
city: "",
address: "",
state: "",
zip: "",
notes: "",
},
};
|