27 lines
766 B
TypeScript
27 lines
766 B
TypeScript
import * as Yup from "yup";
|
|
|
|
export const getInitialValues = (objectToEdit: any): any => {
|
|
return {
|
|
id: objectToEdit?.id ?? null,
|
|
phone_number: objectToEdit?.phone_number ?? null,
|
|
currentModalIndex: 0,
|
|
package_id:objectToEdit?.package_id ?? null
|
|
};
|
|
};
|
|
|
|
export const getValidationSchema = () => {
|
|
return Yup.object().shape({
|
|
phone_number: Yup.string()
|
|
.required("Phone number is required")
|
|
.length(10, "Phone number must be exactly 10 numbers")
|
|
.matches(/^\d{10}$/, "Phone number must be a valid 10-number number"),
|
|
currentModalIndex: Yup.number().max(2)
|
|
});
|
|
};
|
|
|
|
export const getValidationSchemaForSale = () => {
|
|
return Yup.object().shape({
|
|
package_id: Yup.string().required("package_id is required")
|
|
});
|
|
};
|