🚧 More country is not rule

This commit is contained in:
Fred KISSIE
2026-06-25 21:26:13 +02:00
parent 65c383520b
commit 278375f7be
4 changed files with 25 additions and 2 deletions
+11 -1
View File
@@ -966,7 +966,17 @@ export const resourceRules = pgTable("resourceRules", {
enabled: boolean("enabled").notNull().default(true),
priority: integer("priority").notNull(),
action: varchar("action").notNull(), // ACCEPT, DROP, PASS
match: varchar("match").notNull(), // CIDR, PATH, IP
match: varchar("match")
.$type<
| "CIDR"
| "PATH"
| "IP"
| "COUNTRY"
| "COUNTRY_IS_NOT"
| "ASN"
| "REGION"
>()
.notNull(), // CIDR, PATH, IP
value: varchar("value").notNull()
});
+11 -1
View File
@@ -1205,7 +1205,17 @@ export const resourceRules = sqliteTable("resourceRules", {
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
priority: integer("priority").notNull(),
action: text("action").notNull(), // ACCEPT, DROP, PASS
match: text("match").notNull(), // CIDR, PATH, IP
match: text("match")
.$type<
| "CIDR"
| "PATH"
| "IP"
| "COUNTRY"
| "COUNTRY_IS_NOT"
| "ASN"
| "REGION"
>()
.notNull(), // CIDR, PATH, IP
value: text("value").notNull()
});
@@ -27,6 +27,7 @@ const resourceRuleMatchSchema = z.enum([
"IP",
"PATH",
"COUNTRY",
"COUNTRY_IS_NOT",
"ASN",
"REGION"
]);
@@ -144,6 +145,7 @@ export async function updateResourceRule(
| "IP"
| "PATH"
| "COUNTRY"
| "COUNTRY_IS_NOT"
| "ASN"
| "REGION";
@@ -79,6 +79,7 @@ export function createPolicyRuleValueSchema(t: TranslateFn, match: string) {
message: t("rulesErrorInvalidRegionDescription")
});
case "COUNTRY":
case "COUNTRY_IS_NOT":
return required.refine(
(value) => COUNTRIES.some((country) => country.code === value),
{ message: t("rulesErrorInvalidCountryDescription") }