mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-03 09:16:40 +00:00
Enforce fqdn
This commit is contained in:
@@ -34,28 +34,18 @@ const createSiteResourceSchema = z
|
|||||||
// destinationPort: z.int().positive().optional(),
|
// destinationPort: z.int().positive().optional(),
|
||||||
destination: z.string().min(1),
|
destination: z.string().min(1),
|
||||||
enabled: z.boolean().default(true),
|
enabled: z.boolean().default(true),
|
||||||
alias: z.string().optional(),
|
alias: z
|
||||||
|
.string()
|
||||||
|
.regex(
|
||||||
|
/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/,
|
||||||
|
"Alias must be a fully qualified domain name (e.g., example.com)"
|
||||||
|
)
|
||||||
|
.optional(),
|
||||||
userIds: z.array(z.string()),
|
userIds: z.array(z.string()),
|
||||||
roleIds: z.array(z.int()),
|
roleIds: z.array(z.int()),
|
||||||
clientIds: z.array(z.int())
|
clientIds: z.array(z.int())
|
||||||
})
|
})
|
||||||
.strict()
|
.strict()
|
||||||
// .refine(
|
|
||||||
// (data) => {
|
|
||||||
// if (data.mode === "port") {
|
|
||||||
// return (
|
|
||||||
// data.protocol !== undefined &&
|
|
||||||
// data.proxyPort !== undefined &&
|
|
||||||
// data.destinationPort !== undefined
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// message:
|
|
||||||
// "Protocol, proxy port, and destination port are required for port mode"
|
|
||||||
// }
|
|
||||||
// )
|
|
||||||
.refine(
|
.refine(
|
||||||
(data) => {
|
(data) => {
|
||||||
if (data.mode === "host") {
|
if (data.mode === "host") {
|
||||||
|
|||||||
@@ -44,7 +44,13 @@ const updateSiteResourceSchema = z
|
|||||||
// destinationPort: z.int().positive().nullish(),
|
// destinationPort: z.int().positive().nullish(),
|
||||||
destination: z.string().min(1).optional(),
|
destination: z.string().min(1).optional(),
|
||||||
enabled: z.boolean().optional(),
|
enabled: z.boolean().optional(),
|
||||||
alias: z.string().nullish(),
|
alias: z
|
||||||
|
.string()
|
||||||
|
.regex(
|
||||||
|
/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/,
|
||||||
|
"Alias must be a fully qualified domain name (e.g., example.internal)"
|
||||||
|
)
|
||||||
|
.nullish(),
|
||||||
userIds: z.array(z.string()),
|
userIds: z.array(z.string()),
|
||||||
roleIds: z.array(z.int()),
|
roleIds: z.array(z.int()),
|
||||||
clientIds: z.array(z.int())
|
clientIds: z.array(z.int())
|
||||||
|
|||||||
Reference in New Issue
Block a user