mirror of
https://github.com/fosrl/pangolin.git
synced 2026-01-29 06:10:47 +00:00
fix z.coerce.number
This commit is contained in:
@@ -2,11 +2,11 @@ import z from "zod";
|
||||
import ipaddr from "ipaddr.js";
|
||||
|
||||
export function isValidCIDR(cidr: string): boolean {
|
||||
return z.string().cidr().safeParse(cidr).success;
|
||||
return z.cidrv4().safeParse(cidr).success || z.cidrv6().safeParse(cidr).success;
|
||||
}
|
||||
|
||||
export function isValidIP(ip: string): boolean {
|
||||
return z.string().ip().safeParse(ip).success;
|
||||
return z.ipv4().safeParse(ip).success || z.ipv6().safeParse(ip).success;
|
||||
}
|
||||
|
||||
export function isValidUrlGlobPattern(pattern: string): boolean {
|
||||
|
||||
@@ -25,7 +25,7 @@ import { DeleteLoginPageResponse } from "@server/routers/loginPage/types";
|
||||
const paramsSchema = z
|
||||
.object({
|
||||
orgId: z.string(),
|
||||
loginPageId: z.coerce.number()
|
||||
loginPageId: z.coerce.number<number>()
|
||||
})
|
||||
.strict();
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ import { fromError } from "zod-validation-error";
|
||||
import { LoadLoginPageResponse } from "@server/routers/loginPage/types";
|
||||
|
||||
const querySchema = z.object({
|
||||
resourceId: z.coerce.number().int().positive().optional(),
|
||||
idpId: z.coerce.number().int().positive().optional(),
|
||||
resourceId: z.coerce.number<number>().int().positive().optional(),
|
||||
idpId: z.coerce.number<number>().int().positive().optional(),
|
||||
orgId: z.string().min(1).optional(),
|
||||
fullDomain: z.string().min(1)
|
||||
});
|
||||
|
||||
@@ -31,7 +31,7 @@ import { UpdateLoginPageResponse } from "@server/routers/loginPage/types";
|
||||
const paramsSchema = z
|
||||
.object({
|
||||
orgId: z.string(),
|
||||
loginPageId: z.coerce.number()
|
||||
loginPageId: z.coerce.number<number>()
|
||||
})
|
||||
.strict();
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import { OpenAPITags, registry } from "@server/openApi";
|
||||
const paramsSchema = z
|
||||
.object({
|
||||
orgId: z.string().optional(), // Optional; used with org idp in saas
|
||||
idpId: z.coerce.number()
|
||||
idpId: z.coerce.number<number>()
|
||||
})
|
||||
.strict();
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import { GetOrgIdpResponse } from "@server/routers/orgIdp/types";
|
||||
const paramsSchema = z
|
||||
.object({
|
||||
orgId: z.string().nonempty(),
|
||||
idpId: z.coerce.number()
|
||||
idpId: z.coerce.number<number>()
|
||||
})
|
||||
.strict();
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import { TierId } from "@server/lib/billing/tiers";
|
||||
const paramsSchema = z
|
||||
.object({
|
||||
orgId: z.string().nonempty(),
|
||||
idpId: z.coerce.number()
|
||||
idpId: z.coerce.number<number>()
|
||||
})
|
||||
.strict();
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import { eq, and } from "drizzle-orm";
|
||||
import { idp, idpOrg } from "@server/db";
|
||||
|
||||
const paramsSchema = z.strictObject({
|
||||
idpId: z.coerce.number(),
|
||||
idpId: z.coerce.number<number>(),
|
||||
orgId: z.string()
|
||||
});
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import { OpenAPITags, registry } from "@server/openApi";
|
||||
const paramsSchema = z
|
||||
.object({
|
||||
orgId: z.string().optional(), // Optional; used with org idp in saas
|
||||
idpId: z.coerce.number()
|
||||
idpId: z.coerce.number<number>()
|
||||
})
|
||||
.strict();
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import { eq, and } from "drizzle-orm";
|
||||
import { OpenAPITags, registry } from "@server/openApi";
|
||||
|
||||
const paramsSchema = z.strictObject({
|
||||
idpId: z.coerce.number(),
|
||||
idpId: z.coerce.number<number>(),
|
||||
orgId: z.string()
|
||||
});
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import { TierId } from "@server/lib/billing/tiers";
|
||||
|
||||
const paramsSchema = z
|
||||
.object({
|
||||
idpId: z.coerce.number()
|
||||
idpId: z.coerce.number<number>()
|
||||
})
|
||||
.strict();
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import { decrypt } from "@server/lib/crypto";
|
||||
|
||||
const paramsSchema = z
|
||||
.object({
|
||||
idpId: z.coerce.number()
|
||||
idpId: z.coerce.number<number>()
|
||||
})
|
||||
.strict();
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import { fromError } from "zod-validation-error";
|
||||
import { OpenAPITags, registry } from "@server/openApi";
|
||||
|
||||
const paramsSchema = z.object({
|
||||
idpId: z.coerce.number()
|
||||
idpId: z.coerce.number<number>()
|
||||
});
|
||||
|
||||
const querySchema = z.strictObject({
|
||||
|
||||
@@ -11,7 +11,7 @@ import { eq, and } from "drizzle-orm";
|
||||
import { idp, idpOrg } from "@server/db";
|
||||
|
||||
const paramsSchema = z.strictObject({
|
||||
idpId: z.coerce.number(),
|
||||
idpId: z.coerce.number<number>(),
|
||||
orgId: z.string()
|
||||
});
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import config from "@server/lib/config";
|
||||
|
||||
const paramsSchema = z
|
||||
.object({
|
||||
idpId: z.coerce.number()
|
||||
idpId: z.coerce.number<number>()
|
||||
})
|
||||
.strict();
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ const ensureTrailingSlash = (url: string): string => {
|
||||
|
||||
const paramsSchema = z
|
||||
.object({
|
||||
idpId: z.coerce.number()
|
||||
idpId: z.coerce.number<number>()
|
||||
})
|
||||
.strict();
|
||||
|
||||
@@ -51,7 +51,7 @@ const bodySchema = z.object({
|
||||
});
|
||||
|
||||
const querySchema = z.object({
|
||||
loginPageId: z.coerce.number().optional()
|
||||
loginPageId: z.coerce.number<number>().optional()
|
||||
});
|
||||
|
||||
export type ValidateOidcUrlCallbackResponse = {
|
||||
|
||||
@@ -122,7 +122,7 @@ const addTargetSchema = z
|
||||
.object({
|
||||
ip: z.string().refine(isTargetValid),
|
||||
method: z.string().nullable(),
|
||||
port: z.coerce.number().int().positive(),
|
||||
port: z.coerce.number<number>().int().positive(),
|
||||
siteId: z.int()
|
||||
.positive({
|
||||
error: "You must select a site for a target."
|
||||
|
||||
@@ -93,7 +93,7 @@ const addRuleSchema = z.object({
|
||||
action: z.enum(["ACCEPT", "DROP", "PASS"]),
|
||||
match: z.string(),
|
||||
value: z.string(),
|
||||
priority: z.coerce.number().int().optional()
|
||||
priority: z.coerce.number<number>().int().optional()
|
||||
});
|
||||
|
||||
type LocalRule = ArrayElement<ListResourceRulesResponse["rules"]> & {
|
||||
|
||||
@@ -136,7 +136,7 @@ const addTargetSchema = z
|
||||
.object({
|
||||
ip: z.string().refine(isTargetValid),
|
||||
method: z.string().nullable(),
|
||||
port: z.coerce.number().int().positive(),
|
||||
port: z.coerce.number<number>().int().positive(),
|
||||
siteId: z.int().positive(),
|
||||
path: z.string().optional().nullable(),
|
||||
pathMatchType: z
|
||||
|
||||
@@ -108,7 +108,7 @@ export default function CreateShareLinkForm({
|
||||
resourceName: z.string(),
|
||||
resourceUrl: z.string(),
|
||||
timeUnit: z.string(),
|
||||
timeValue: z.coerce.number().int().positive().min(1),
|
||||
timeValue: z.coerce.number<number>().int().positive().min(1),
|
||||
title: z.string().optional()
|
||||
});
|
||||
|
||||
|
||||
@@ -81,8 +81,8 @@ export default function GenerateLicenseKeyForm({
|
||||
jobTitle: z.string().min(1),
|
||||
primaryUse: z.string().min(1),
|
||||
industry: z.string().min(1),
|
||||
prospectiveUsers: z.coerce.number().optional(),
|
||||
prospectiveSites: z.coerce.number().optional(),
|
||||
prospectiveUsers: z.coerce.number<number>().optional(),
|
||||
prospectiveSites: z.coerce.number<number>().optional(),
|
||||
companyName: z.string().min(1),
|
||||
countryOfResidence: z.string().min(1),
|
||||
stateProvinceRegion: z.string().min(1),
|
||||
|
||||
Reference in New Issue
Block a user