mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-16 01:46:38 +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 = {
|
||||
|
||||
Reference in New Issue
Block a user