mirror of
https://github.com/certimate-go/certimate.git
synced 2026-06-30 21:05:12 +08:00
refactor: clean code
This commit is contained in:
parent
d49f543247
commit
af50635751
@ -4,7 +4,7 @@ import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import Show from "@/components/Show";
|
||||
import { isDomain, isEmail, isIPv4, isIPv6, isPortNumber } from "@/utils/validator";
|
||||
import { isEmail, isHostname, isPortNumber } from "@/utils/validator";
|
||||
|
||||
import { useFormNestedFieldsContext } from "./_context";
|
||||
|
||||
@ -127,7 +127,7 @@ const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) =
|
||||
const { t } = i18n;
|
||||
|
||||
return z.object({
|
||||
smtpHost: z.string().refine((v) => isDomain(v) || isIPv4(v) || isIPv6(v), t("common.errmsg.host_invalid")),
|
||||
smtpHost: z.string().refine((v) => isHostname(v), t("common.errmsg.host_invalid")),
|
||||
smtpPort: z.coerce.number().refine((v) => isPortNumber(v), t("common.errmsg.port_invalid")),
|
||||
smtpTls: z.boolean().nullish(),
|
||||
username: z.string().nonempty(t("access.form.email_username.placeholder")),
|
||||
|
||||
@ -110,7 +110,8 @@ const getSchema = ({ i18n = getI18n() }: { i18n?: ReturnType<typeof getI18n> })
|
||||
.string()
|
||||
.nullish()
|
||||
.refine((v) => {
|
||||
return !v || isDomain(v!, { allowWildcard: true });
|
||||
if (!v) return true;
|
||||
return isDomain(v, { allowWildcard: true });
|
||||
}, t("common.errmsg.domain_invalid")),
|
||||
})
|
||||
.superRefine((values, ctx) => {
|
||||
|
||||
@ -110,7 +110,8 @@ const getSchema = ({ i18n = getI18n() }: { i18n?: ReturnType<typeof getI18n> })
|
||||
.string()
|
||||
.nullish()
|
||||
.refine((v) => {
|
||||
return !v || isDomain(v!, { allowWildcard: true });
|
||||
if (!v) return true;
|
||||
return isDomain(v, { allowWildcard: true });
|
||||
}, t("common.errmsg.domain_invalid")),
|
||||
})
|
||||
.superRefine((values, ctx) => {
|
||||
|
||||
@ -97,7 +97,8 @@ const getSchema = ({ i18n = getI18n() }: { i18n?: ReturnType<typeof getI18n> })
|
||||
.string()
|
||||
.nullish()
|
||||
.refine((v) => {
|
||||
return !v || isDomain(v!);
|
||||
if (!v) return true;
|
||||
return isDomain(v);
|
||||
}, t("common.errmsg.domain_invalid")),
|
||||
})
|
||||
.superRefine((values, ctx) => {
|
||||
|
||||
@ -150,7 +150,8 @@ const getSchema = ({ i18n = getI18n() }: { i18n?: ReturnType<typeof getI18n> })
|
||||
.string()
|
||||
.nullish()
|
||||
.refine((v) => {
|
||||
return !v || isDomain(v!, { allowWildcard: true });
|
||||
if (!v) return true;
|
||||
return isDomain(v, { allowWildcard: true });
|
||||
}, t("common.errmsg.domain_invalid")),
|
||||
})
|
||||
.superRefine((values, ctx) => {
|
||||
|
||||
@ -110,7 +110,8 @@ const getSchema = ({ i18n = getI18n() }: { i18n?: ReturnType<typeof getI18n> })
|
||||
.string()
|
||||
.nullish()
|
||||
.refine((v) => {
|
||||
return !v || isDomain(v!, { allowWildcard: true });
|
||||
if (!v) return true;
|
||||
return isDomain(v, { allowWildcard: true });
|
||||
}, t("common.errmsg.domain_invalid")),
|
||||
})
|
||||
.superRefine((values, ctx) => {
|
||||
|
||||
@ -110,7 +110,8 @@ const getSchema = ({ i18n = getI18n() }: { i18n?: ReturnType<typeof getI18n> })
|
||||
.string()
|
||||
.nullish()
|
||||
.refine((v) => {
|
||||
return !v || isDomain(v!, { allowWildcard: true });
|
||||
if (!v) return true;
|
||||
return isDomain(v, { allowWildcard: true });
|
||||
}, t("common.errmsg.domain_invalid")),
|
||||
})
|
||||
.superRefine((values, ctx) => {
|
||||
|
||||
@ -110,7 +110,8 @@ const getSchema = ({ i18n = getI18n() }: { i18n?: ReturnType<typeof getI18n> })
|
||||
.string()
|
||||
.nullish()
|
||||
.refine((v) => {
|
||||
return !v || isDomain(v!, { allowWildcard: true });
|
||||
if (!v) return true;
|
||||
return isDomain(v, { allowWildcard: true });
|
||||
}, t("common.errmsg.domain_invalid")),
|
||||
})
|
||||
.superRefine((values, ctx) => {
|
||||
|
||||
@ -111,7 +111,8 @@ const getSchema = ({ i18n = getI18n() }: { i18n?: ReturnType<typeof getI18n> })
|
||||
.string()
|
||||
.nullish()
|
||||
.refine((v) => {
|
||||
return !v || isDomain(v);
|
||||
if (!v) return true;
|
||||
return isDomain(v);
|
||||
}, t("common.errmsg.domain_invalid")),
|
||||
})
|
||||
.superRefine((values, ctx) => {
|
||||
|
||||
@ -110,7 +110,8 @@ const getSchema = ({ i18n = getI18n() }: { i18n?: ReturnType<typeof getI18n> })
|
||||
.string()
|
||||
.nullish()
|
||||
.refine((v) => {
|
||||
return !v || isDomain(v!, { allowWildcard: true });
|
||||
if (!v) return true;
|
||||
return isDomain(v, { allowWildcard: true });
|
||||
}, t("common.errmsg.domain_invalid")),
|
||||
})
|
||||
.superRefine((values, ctx) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user