mirror of
https://github.com/fosrl/pangolin.git
synced 2025-12-14 12:08:11 +00:00
subdomain validation consistent
This commit is contained in:
@@ -1,18 +1,24 @@
|
||||
import { z } from "zod";
|
||||
|
||||
|
||||
export const subdomainSchema = z
|
||||
.string()
|
||||
.regex(
|
||||
/^(?!:\/\/)([a-zA-Z0-9-_]+\.)*[a-zA-Z0-9-_]+$/,
|
||||
/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/,
|
||||
"Invalid subdomain format"
|
||||
)
|
||||
.min(1, "Subdomain must be at least 1 character long")
|
||||
.max(63, "Subdomain must not exceed 63 characters")
|
||||
.transform((val) => val.toLowerCase());
|
||||
|
||||
export const tlsNameSchema = z
|
||||
.string()
|
||||
.regex(
|
||||
/^(?!:\/\/)([a-zA-Z0-9-_]+\.)*[a-zA-Z0-9-_]+$|^$/,
|
||||
/^([a-z0-9](?:[a-z0-9-]*[a-z0-9])?)(\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)*$/,
|
||||
"Invalid subdomain format"
|
||||
)
|
||||
).max(253, "Domain must not exceed 253 characters")
|
||||
.refine((val) => {
|
||||
const labels = val.split('.');
|
||||
return labels.every((label) => label.length <= 63);
|
||||
}, "Each part of the domain must not exceed 63 characters")
|
||||
.transform((val) => val.toLowerCase());
|
||||
Reference in New Issue
Block a user