MCPcopy Create free account
hub / github.com/Codehagen/Badget / validateFilterValue

Function validateFilterValue

src/lib/filter-utils.ts:73–97  ·  view source on GitHub ↗
(
  key: keyof TransactionFilters,
  value: unknown
)

Source from the content-addressed store, hash-verified

71}
72
73export function validateFilterValue(
74 key: keyof TransactionFilters,
75 value: unknown
76): boolean {
77 switch (key) {
78 case "status":
79 return [
80 "RECONCILED",
81 "NEEDS_CATEGORIZATION",
82 "NEEDS_REVIEW",
83 "IN_PROGRESS",
84 ].includes(value);
85 case "type":
86 return ["INCOME", "EXPENSE", "TRANSFER"].includes(value);
87 case "startDate":
88 case "endDate":
89 return value instanceof Date && !isNaN(value.getTime());
90 case "search":
91 case "accountId":
92 case "categoryId":
93 return typeof value === "string";
94 default:
95 return true;
96 }
97}
98
99export function countActiveFilters(filters: TransactionFilters): number {
100 return Object.values(filters).filter((value) => {

Callers 1

useTransactionFiltersFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected