import { z } from "zod";
import { digitField } from "./common.schema";
import { BankAccountType, Status } from "@/constants/constants";

export const bankAccountFormSchema = z.object({
  bankName: z
  .string({ required_error: "Please select a bank name" })
  .min(1, "Please select a bank name"),
  accountNumber: digitField({
    min: 9,
    max: 18,
    required: true,
    invalidTypeError: "Account number must be a 6-digit numeric string",
  }),
  ifscCode: z
    .string()
    .length(11, { message: "IFSC code must be exactly 11 characters" })
    .regex(/^[A-Z]{4}0[A-Z0-9]{6}$/, {
      message: "IFSC code must be in the format AAAA0XXXXXX",
    }),
  branch: z
    .string()
    .min(2, { message: "Branch name must be at least 2 characters" })
    .max(100, { message: "Branch name must be less than 100 characters" }),
  accountType: z.nativeEnum(BankAccountType, {
    required_error: "Please select an account type",
    invalid_type_error: "Account type must be one of: savings, current",
  }),
  status: z.nativeEnum(Status, {
    required_error: "Please select a status",
    invalid_type_error: "Status must be one of: active, inActive",
  }),
});
