Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions src/_BacktestingPage/utils/backtestFormSchema.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { z } from "zod";
import { differenceInMonths, differenceInYears } from "date-fns";
import { differenceInMonths } from "date-fns";

const TODAY = new Date();
const MIN_DATE = new Date("1990-01-01"); // 1990년 1월 1일
const MIN_MONTHS_DIFF = 3; // 최소 3개월
const MAX_YEARS_DIFF = 10; // 최대 10년

export const backtestFormSchema = z
.object({
Expand Down Expand Up @@ -33,15 +32,5 @@ export const backtestFormSchema = z
message: `시작일은 종료일보다 최소 ${MIN_MONTHS_DIFF}개월 전이어야 합니다.`,
path: ["startDate"],
}
)
.refine(
(data) => {
const yearsDiff = differenceInYears(data.endDate, data.startDate);
return yearsDiff <= MAX_YEARS_DIFF;
},
{
message: `시작일은 종료일보다 최대 ${MAX_YEARS_DIFF}년 전까지 가능합니다.`,
path: ["startDate"],
}
);
export type BacktestFormSchema = z.infer<typeof backtestFormSchema>;