diff --git a/web/src/pages/acl/AclIndexPage/components/AclIndexAliases/modals/AlcAliasCEModal/AlcAliasCEModal.tsx b/web/src/pages/acl/AclIndexPage/components/AclIndexAliases/modals/AlcAliasCEModal/AlcAliasCEModal.tsx index 7eb64c9ec8..6a68bf7900 100644 --- a/web/src/pages/acl/AclIndexPage/components/AclIndexAliases/modals/AlcAliasCEModal/AlcAliasCEModal.tsx +++ b/web/src/pages/acl/AclIndexPage/components/AclIndexAliases/modals/AlcAliasCEModal/AlcAliasCEModal.tsx @@ -84,6 +84,7 @@ const ModalContent = () => { .string({ required_error: formErrors.required(), }) + .trim() .min(1, formErrors.required()), kind: z.nativeEnum(AclAliasKind), ports: aclPortsValidator(LL), diff --git a/web/src/pages/addDevice/steps/AddDeviceSetupStep/AddDeviceSetupStep.tsx b/web/src/pages/addDevice/steps/AddDeviceSetupStep/AddDeviceSetupStep.tsx index 466498ea86..f71c05c166 100644 --- a/web/src/pages/addDevice/steps/AddDeviceSetupStep/AddDeviceSetupStep.tsx +++ b/web/src/pages/addDevice/steps/AddDeviceSetupStep/AddDeviceSetupStep.tsx @@ -65,11 +65,12 @@ export const AddDeviceSetupStep = () => { choice: z.nativeEnum(AddNativeWgDeviceMode), name: z .string() + .trim() .min(4, LL.form.error.minimumLength()) .refine((val) => !userData?.reservedDevices?.includes(val), { message: localLL.form.errors.name.duplicatedName(), }), - publicKey: z.string(), + publicKey: z.string().trim(), }) .superRefine((val, ctx) => { const { publicKey, choice } = val; diff --git a/web/src/pages/auth/Login/Login.tsx b/web/src/pages/auth/Login/Login.tsx index 0f25007922..6e55a34dff 100644 --- a/web/src/pages/auth/Login/Login.tsx +++ b/web/src/pages/auth/Login/Login.tsx @@ -56,11 +56,13 @@ export const Login = () => { z.object({ username: z .string() + .trim() .min(1, LL.form.error.minimumLength()) .max(64) .regex(patternLoginCharacters, LL.form.error.forbiddenCharacter()), password: z .string() + .trim() .min(1, LL.form.error.required()) .max(128, LL.form.error.maximumLength()), }), diff --git a/web/src/pages/auth/MFARoute/MFAEmail/MFAEmail.tsx b/web/src/pages/auth/MFARoute/MFAEmail/MFAEmail.tsx index 73fad33547..8bc85d6afe 100644 --- a/web/src/pages/auth/MFARoute/MFAEmail/MFAEmail.tsx +++ b/web/src/pages/auth/MFARoute/MFAEmail/MFAEmail.tsx @@ -57,6 +57,7 @@ export const MFAEmail = () => { z.object({ code: z .string() + .trim() .min(6, LL.form.error.minimumLength()) .max(6, LL.form.error.maximumLength()) .regex(patternNumbersOnly, LL.form.error.invalid()), diff --git a/web/src/pages/auth/MFARoute/MFATOTPAuth/MFATOTPAuth.tsx b/web/src/pages/auth/MFARoute/MFATOTPAuth/MFATOTPAuth.tsx index d3a5432b1a..bd3ce1b3ae 100644 --- a/web/src/pages/auth/MFARoute/MFATOTPAuth/MFATOTPAuth.tsx +++ b/web/src/pages/auth/MFARoute/MFATOTPAuth/MFATOTPAuth.tsx @@ -51,6 +51,7 @@ export const MFATOTPAuth = () => { z.object({ code: z .string() + .trim() .min(6, LL.form.error.validCode()) .max(6, LL.form.error.validCode()), }), diff --git a/web/src/pages/devices/modals/components/StandaloneDeviceModalForm/formSchema.ts b/web/src/pages/devices/modals/components/StandaloneDeviceModalForm/formSchema.ts index 51fdb34673..e43a1aaaf9 100644 --- a/web/src/pages/devices/modals/components/StandaloneDeviceModalForm/formSchema.ts +++ b/web/src/pages/devices/modals/components/StandaloneDeviceModalForm/formSchema.ts @@ -21,6 +21,7 @@ export const standaloneDeviceFormSchema = ( .object({ name: z .string() + .trim() .min(1, LL.form.error.required()) .refine((value) => { if (mode === StandaloneDeviceModalFormMode.EDIT && isPresent(originalName)) { @@ -30,10 +31,10 @@ export const standaloneDeviceFormSchema = ( return !reservedNames.includes(value.trim()); }, LL.form.error.reservedName()), location_id: z.number(), - description: z.string().optional(), - modifiableIpParts: z.array(z.string().min(1, LL.form.error.required())), + description: z.string().trim().optional(), + modifiableIpParts: z.array(z.string().trim().min(1, LL.form.error.required())), generationChoice: z.nativeEnum(WGConfigGenChoice), - wireguard_pubkey: z.string().optional(), + wireguard_pubkey: z.string().trim().optional(), }) .superRefine((vals, ctx) => { if (mode === StandaloneDeviceModalFormMode.CREATE_MANUAL) { diff --git a/web/src/pages/groups/components/modals/AddGroupModal/AddGroupModal.tsx b/web/src/pages/groups/components/modals/AddGroupModal/AddGroupModal.tsx index d453a99ea3..2dc07e45d4 100644 --- a/web/src/pages/groups/components/modals/AddGroupModal/AddGroupModal.tsx +++ b/web/src/pages/groups/components/modals/AddGroupModal/AddGroupModal.tsx @@ -114,6 +114,7 @@ const ModalContent = () => { .string({ required_error: LL.form.error.required(), }) + .trim() .min(4, LL.form.error.minimumLength()) .refine((name) => { // if in edit mode ignore self name diff --git a/web/src/pages/network/NetworkEditForm/NetworkEditForm.tsx b/web/src/pages/network/NetworkEditForm/NetworkEditForm.tsx index af570538f6..f73bcecd00 100644 --- a/web/src/pages/network/NetworkEditForm/NetworkEditForm.tsx +++ b/web/src/pages/network/NetworkEditForm/NetworkEditForm.tsx @@ -117,12 +117,14 @@ export const NetworkEditForm = () => { name: z.string().min(1, LL.form.error.required()), address: z .string() + .trim() .min(1, LL.form.error.required()) .refine((value) => { return validateIpList(value, ',', true); }, LL.form.error.addressNetmask()), endpoint: z .string() + .trim() .min(1, LL.form.error.required()) .refine( (val) => validateIpOrDomain(val, false, true), @@ -136,6 +138,7 @@ export const NetworkEditForm = () => { allowed_ips: z.string(), dns: z .string() + .trim() .optional() .refine((val) => { if (val === '' || !val) { diff --git a/web/src/pages/openid/modals/OpenIdClientModal/OpenIdClientModalForm.tsx b/web/src/pages/openid/modals/OpenIdClientModal/OpenIdClientModalForm.tsx index d184d688b6..e6d4af4d13 100644 --- a/web/src/pages/openid/modals/OpenIdClientModal/OpenIdClientModalForm.tsx +++ b/web/src/pages/openid/modals/OpenIdClientModal/OpenIdClientModalForm.tsx @@ -95,6 +95,7 @@ export const OpenIdClientModalForm = () => { z.object({ name: z .string() + .trim() .min(4, LL.form.error.minimumLength()) .max(16, LL.form.error.maximumLength()) .min(1, LL.form.error.required()), @@ -102,6 +103,7 @@ export const OpenIdClientModalForm = () => { z.object({ url: z .string() + .trim() .min( 1, LL.openidOverview.modals.openidClientModal.form.error.urlRequired(), diff --git a/web/src/pages/settings/components/ActivityLogStreamSettings/modals/LogStashHttpStreamCEModal/LogStashHttpStreamCEModal.tsx b/web/src/pages/settings/components/ActivityLogStreamSettings/modals/LogStashHttpStreamCEModal/LogStashHttpStreamCEModal.tsx index 8899f546af..b983c44267 100644 --- a/web/src/pages/settings/components/ActivityLogStreamSettings/modals/LogStashHttpStreamCEModal/LogStashHttpStreamCEModal.tsx +++ b/web/src/pages/settings/components/ActivityLogStreamSettings/modals/LogStashHttpStreamCEModal/LogStashHttpStreamCEModal.tsx @@ -111,11 +111,15 @@ const ModalContent = () => { const schema = useMemo( () => z.object({ - name: z.string().min(1, LL.form.error.required()), - url: z.string().min(1, LL.form.error.required()).url(LL.form.error.urlInvalid()), - username: z.string(), - password: z.string(), - cert: z.string(), + name: z.string().trim().min(1, LL.form.error.required()), + url: z + .string() + .trim() + .min(1, LL.form.error.required()) + .url(LL.form.error.urlInvalid()), + username: z.string().trim(), + password: z.string().trim(), + cert: z.string().trim(), }), [LL.form.error], ); diff --git a/web/src/pages/settings/components/ActivityLogStreamSettings/modals/VectorHttpStreamCEModal/VectorHttpStreamCEModal.tsx b/web/src/pages/settings/components/ActivityLogStreamSettings/modals/VectorHttpStreamCEModal/VectorHttpStreamCEModal.tsx index 59d0a495d5..51acd555b8 100644 --- a/web/src/pages/settings/components/ActivityLogStreamSettings/modals/VectorHttpStreamCEModal/VectorHttpStreamCEModal.tsx +++ b/web/src/pages/settings/components/ActivityLogStreamSettings/modals/VectorHttpStreamCEModal/VectorHttpStreamCEModal.tsx @@ -64,11 +64,15 @@ const ModalContent = () => { const schema = useMemo( () => z.object({ - name: z.string().min(1, LL.form.error.required()), - url: z.string().min(1, LL.form.error.required()).url(LL.form.error.urlInvalid()), - username: z.string(), - password: z.string(), - cert: z.string(), + name: z.string().trim().min(1, LL.form.error.required()), + url: z + .string() + .trim() + .min(1, LL.form.error.required()) + .url(LL.form.error.urlInvalid()), + username: z.string().trim(), + password: z.string().trim(), + cert: z.string().trim(), }), [LL.form.error], ); diff --git a/web/src/pages/settings/components/GlobalSettings/types.ts b/web/src/pages/settings/components/GlobalSettings/types.ts index 342f24b59d..85875150ba 100644 --- a/web/src/pages/settings/components/GlobalSettings/types.ts +++ b/web/src/pages/settings/components/GlobalSettings/types.ts @@ -3,17 +3,18 @@ import type { TranslationFunctions } from '../../../../i18n/i18n-types'; export const globalSettingsSchema = (LL: TranslationFunctions) => z.object({ - main_logo_url: z.string(), - nav_logo_url: z.string(), + main_logo_url: z.string().trim(), + nav_logo_url: z.string().trim(), instance_name: z .string() + .trim() .min(3, LL.form.error.minimumLength()) .max(64, LL.form.error.maximumLength()), openid_enabled: z.boolean(), wireguard_enabled: z.boolean(), worker_enabled: z.boolean(), webhooks_enabled: z.boolean(), - license: z.string().optional(), + license: z.string().trim().optional(), }); export type GlobalSettingsFormFields = z.infer>; diff --git a/web/src/pages/settings/components/LdapSettings/components/LdapSettingsForm.tsx b/web/src/pages/settings/components/LdapSettings/components/LdapSettingsForm.tsx index 00c01379d9..e4bf6369e5 100644 --- a/web/src/pages/settings/components/LdapSettings/components/LdapSettingsForm.tsx +++ b/web/src/pages/settings/components/LdapSettings/components/LdapSettingsForm.tsx @@ -72,19 +72,20 @@ export const LdapSettingsForm = () => { z.object({ ldap_url: z .string() + .trim() .url(LL.form.error.invalid()) .min(1, LL.form.error.required()), - ldap_bind_username: z.string().min(1, LL.form.error.required()), - ldap_bind_password: z.string(), - ldap_group_member_attr: z.string().min(1, LL.form.error.required()), - ldap_group_obj_class: z.string().min(1, LL.form.error.required()), - ldap_group_search_base: z.string().min(1, LL.form.error.required()), - ldap_groupname_attr: z.string().min(1, LL.form.error.required()), - ldap_member_attr: z.string().min(1, LL.form.error.required()), - ldap_user_obj_class: z.string().min(1, LL.form.error.required()), - ldap_user_auxiliary_obj_classes: z.string(), - ldap_user_search_base: z.string().min(1, LL.form.error.required()), - ldap_username_attr: z.string().min(1, LL.form.error.required()), + ldap_bind_username: z.string().trim().min(1, LL.form.error.required()), + ldap_bind_password: z.string().trim(), + ldap_group_member_attr: z.string().trim().min(1, LL.form.error.required()), + ldap_group_obj_class: z.string().trim().min(1, LL.form.error.required()), + ldap_group_search_base: z.string().trim().min(1, LL.form.error.required()), + ldap_groupname_attr: z.string().trim().min(1, LL.form.error.required()), + ldap_member_attr: z.string().trim().min(1, LL.form.error.required()), + ldap_user_obj_class: z.string().trim().min(1, LL.form.error.required()), + ldap_user_auxiliary_obj_classes: z.string().trim(), + ldap_user_search_base: z.string().trim().min(1, LL.form.error.required()), + ldap_username_attr: z.string().trim().min(1, LL.form.error.required()), ldap_enabled: z.boolean(), ldap_sync_enabled: z.boolean(), ldap_is_authoritative: z.boolean(), @@ -92,8 +93,8 @@ export const LdapSettingsForm = () => { ldap_tls_verify_cert: z.boolean(), ldap_sync_interval: z.number().default(300), ldap_uses_ad: z.boolean(), - ldap_user_rdn_attr: z.string().optional(), - ldap_sync_groups: z.string(), + ldap_user_rdn_attr: z.string().trim().optional(), + ldap_sync_groups: z.string().trim(), }), [LL.form.error], ); diff --git a/web/src/pages/settings/components/SmtpSettings/components/SmtpSettingsForm/SmtpSettingsForm.tsx b/web/src/pages/settings/components/SmtpSettings/components/SmtpSettingsForm/SmtpSettingsForm.tsx index 06be6a4ab5..55db9997b5 100644 --- a/web/src/pages/settings/components/SmtpSettings/components/SmtpSettingsForm/SmtpSettingsForm.tsx +++ b/web/src/pages/settings/components/SmtpSettings/components/SmtpSettingsForm/SmtpSettingsForm.tsx @@ -109,6 +109,7 @@ export const SmtpSettingsForm = () => { z.object({ smtp_server: z .string() + .trim() .min(1, LL.form.error.required()) .refine( (val) => (!val ? true : validateIpOrDomain(val, false, true)), @@ -119,13 +120,14 @@ export const SmtpSettingsForm = () => { invalid_type_error: LL.form.error.required(), }) .max(65535, LL.form.error.portMax()), - smtp_password: z.string(), - smtp_user: z.string(), + smtp_password: z.string().trim(), + smtp_user: z.string().trim(), smtp_sender: z .string() + .trim() .min(1, LL.form.error.required()) .regex(patternValidEmail, LL.form.error.invalid()), - smtp_encryption: z.string().min(1, LL.form.error.required()), + smtp_encryption: z.string().trim().min(1, LL.form.error.required()), }), [LL.form], ); diff --git a/web/src/pages/settings/components/SmtpSettings/components/SmtpTest/SmtpTest.tsx b/web/src/pages/settings/components/SmtpSettings/components/SmtpTest/SmtpTest.tsx index 17a6408bf4..ad2050366c 100644 --- a/web/src/pages/settings/components/SmtpSettings/components/SmtpTest/SmtpTest.tsx +++ b/web/src/pages/settings/components/SmtpSettings/components/SmtpTest/SmtpTest.tsx @@ -46,7 +46,7 @@ export const SmtpTest = () => { const zodSchema = useMemo( () => z.object({ - to: z.string().regex(patternValidEmail, LL.form.error.invalid()), + to: z.string().trim().regex(patternValidEmail, LL.form.error.invalid()), }), [LL.form.error], ); diff --git a/web/src/pages/settings/components/SmtpSettings/components/SmtpTest/SmtpTestModal.tsx b/web/src/pages/settings/components/SmtpSettings/components/SmtpTest/SmtpTestModal.tsx index a795708a88..9f33fffda5 100644 --- a/web/src/pages/settings/components/SmtpSettings/components/SmtpTest/SmtpTestModal.tsx +++ b/web/src/pages/settings/components/SmtpSettings/components/SmtpTest/SmtpTestModal.tsx @@ -48,7 +48,7 @@ const ModalContent = () => { const zodSchema = useMemo( () => z.object({ - to: z.string().regex(patternValidEmail, LL.form.error.invalid()), + to: z.string().trim().regex(patternValidEmail, LL.form.error.invalid()), }), [LL.form.error], ); diff --git a/web/src/pages/users/UserProfile/ProfileDetails/ProfileDetailsForm/ProfileDetailsForm.tsx b/web/src/pages/users/UserProfile/ProfileDetails/ProfileDetailsForm/ProfileDetailsForm.tsx index 293ee5d109..eb84d88e64 100644 --- a/web/src/pages/users/UserProfile/ProfileDetails/ProfileDetailsForm/ProfileDetailsForm.tsx +++ b/web/src/pages/users/UserProfile/ProfileDetails/ProfileDetailsForm/ProfileDetailsForm.tsx @@ -84,13 +84,15 @@ export const ProfileDetailsForm = () => { z.object({ username: z .string() + .trim() .min(1, LL.form.error.minimumLength()) .regex(patternSafeUsernameCharacters, LL.form.error.forbiddenCharacter()) .max(64, LL.form.error.maximumLength()), - first_name: z.string().min(1, LL.form.error.required()), - last_name: z.string().min(1, LL.form.error.required()), + first_name: z.string().trim().min(1, LL.form.error.required()), + last_name: z.string().trim().min(1, LL.form.error.required()), phone: z .string() + .trim() .optional() .refine((val) => { if (val && values.length > 0) { @@ -100,13 +102,14 @@ export const ProfileDetailsForm = () => { }, LL.form.error.invalid()), email: z .string() + .trim() .min(1, LL.form.error.required()) .regex(patternValidEmail, LL.form.error.invalid()), - groups: z.array(z.string().min(1, LL.form.error.required())), + groups: z.array(z.string().trim().min(1, LL.form.error.required())), authorized_apps: z.array( z.object({ oauth2client_id: z.number().min(1, LL.form.error.required()), - oauth2client_name: z.string().min(1, LL.form.error.required()), + oauth2client_name: z.string().trim().min(1, LL.form.error.required()), user_id: z.number().min(1, LL.form.error.required()), }), ), diff --git a/web/src/pages/users/UserProfile/UserAuthInfo/modals/ManageWebAuthNModal/components/RegisterWebAuthNForm.tsx b/web/src/pages/users/UserProfile/UserAuthInfo/modals/ManageWebAuthNModal/components/RegisterWebAuthNForm.tsx index 1b56a8c2dc..f631c5aaf2 100644 --- a/web/src/pages/users/UserProfile/UserAuthInfo/modals/ManageWebAuthNModal/components/RegisterWebAuthNForm.tsx +++ b/web/src/pages/users/UserProfile/UserAuthInfo/modals/ManageWebAuthNModal/components/RegisterWebAuthNForm.tsx @@ -68,6 +68,7 @@ export const RegisterWebAuthNForm = () => { z.object({ name: z .string() + .trim() .min(1, LL.form.error.required()) .min(4, LL.form.error.minimumLength()), }), diff --git a/web/src/pages/users/UserProfile/UserAuthInfo/modals/RegisterEmailMFAModal/components/RegisterMFAEmailForm/RegisterMFAEmailForm.tsx b/web/src/pages/users/UserProfile/UserAuthInfo/modals/RegisterEmailMFAModal/components/RegisterMFAEmailForm/RegisterMFAEmailForm.tsx index 0926c8595e..7a2cf1f85c 100644 --- a/web/src/pages/users/UserProfile/UserAuthInfo/modals/RegisterEmailMFAModal/components/RegisterMFAEmailForm/RegisterMFAEmailForm.tsx +++ b/web/src/pages/users/UserProfile/UserAuthInfo/modals/RegisterEmailMFAModal/components/RegisterMFAEmailForm/RegisterMFAEmailForm.tsx @@ -55,6 +55,7 @@ export const RegisterMFAEmailForm = () => { z.object({ code: z .string() + .trim() .regex(patternNumbersOnly, LL.form.error.invalid()) .min(6, LL.form.error.minimumLength()) .max(6, LL.form.error.maximumLength()), diff --git a/web/src/pages/users/UserProfile/UserAuthInfo/modals/RegisterTOTPModal/RegisterTOTPModal.tsx b/web/src/pages/users/UserProfile/UserAuthInfo/modals/RegisterTOTPModal/RegisterTOTPModal.tsx index 77a7dbc09b..236fc7bddf 100644 --- a/web/src/pages/users/UserProfile/UserAuthInfo/modals/RegisterTOTPModal/RegisterTOTPModal.tsx +++ b/web/src/pages/users/UserProfile/UserAuthInfo/modals/RegisterTOTPModal/RegisterTOTPModal.tsx @@ -138,7 +138,7 @@ const TOTPRegisterForm = () => { const zodSchema = useMemo( () => z.object({ - code: z.string().min(6, LL.form.error.minimumLength()), + code: z.string().trim().min(6, LL.form.error.minimumLength()), }), [LL.form.error], ); diff --git a/web/src/pages/users/UserProfile/UserDevices/modals/EditUserDeviceModal/UserDeviceEditForm.tsx b/web/src/pages/users/UserProfile/UserDevices/modals/EditUserDeviceModal/UserDeviceEditForm.tsx index ecf94939d7..b251ce6126 100644 --- a/web/src/pages/users/UserProfile/UserDevices/modals/EditUserDeviceModal/UserDeviceEditForm.tsx +++ b/web/src/pages/users/UserProfile/UserDevices/modals/EditUserDeviceModal/UserDeviceEditForm.tsx @@ -41,10 +41,12 @@ export const EditUserDeviceForm = () => { z.object({ name: z .string() + .trim() .min(4, LL.form.error.minimumLength()) .regex(patternNoSpecialChars, LL.form.error.noSpecialChars()), wireguard_pubkey: z .string() + .trim() .min(44, LL.form.error.invalidKey()) .max(44, LL.form.error.invalidKey()) .regex(patternValidWireguardKey, LL.form.error.invalidKey()), diff --git a/web/src/pages/users/shared/modals/AddApiTokenModal/components/AddApiTokenForm/AddApiTokenForm.tsx b/web/src/pages/users/shared/modals/AddApiTokenModal/components/AddApiTokenForm/AddApiTokenForm.tsx index 7897e5f3fc..b2fe6c82c8 100644 --- a/web/src/pages/users/shared/modals/AddApiTokenModal/components/AddApiTokenForm/AddApiTokenForm.tsx +++ b/web/src/pages/users/shared/modals/AddApiTokenModal/components/AddApiTokenForm/AddApiTokenForm.tsx @@ -69,6 +69,7 @@ export const AddApiTokenForm = () => { .string({ required_error: LL.form.error.required(), }) + .trim() .min(1, LL.form.error.required()) .min(4, LL.form.error.minimumLength()), }), diff --git a/web/src/pages/users/shared/modals/AddAuthenticationKeyModal/components/AddAuthenticationKeyForm/AddAuthenticationKeyForm.tsx b/web/src/pages/users/shared/modals/AddAuthenticationKeyModal/components/AddAuthenticationKeyForm/AddAuthenticationKeyForm.tsx index 3b322598c8..fedc297ed8 100644 --- a/web/src/pages/users/shared/modals/AddAuthenticationKeyModal/components/AddAuthenticationKeyForm/AddAuthenticationKeyForm.tsx +++ b/web/src/pages/users/shared/modals/AddAuthenticationKeyModal/components/AddAuthenticationKeyForm/AddAuthenticationKeyForm.tsx @@ -67,11 +67,14 @@ export const AddAuthenticationKeyForm = ({ keyType }: Props) => { .string({ required_error: LL.form.error.required(), }) + .trim() .min(1, LL.form.error.required()) .min(4, LL.form.error.minimumLength()), - keyValue: z.string({ - required_error: LL.form.error.required(), - }), + keyValue: z + .string({ + required_error: LL.form.error.required(), + }) + .trim(), }), [LL.form.error], ); diff --git a/web/src/pages/users/shared/modals/RenameApiTokenModal/RenameApiTokenModal.tsx b/web/src/pages/users/shared/modals/RenameApiTokenModal/RenameApiTokenModal.tsx index 5f6039691f..033c87754e 100644 --- a/web/src/pages/users/shared/modals/RenameApiTokenModal/RenameApiTokenModal.tsx +++ b/web/src/pages/users/shared/modals/RenameApiTokenModal/RenameApiTokenModal.tsx @@ -55,6 +55,7 @@ const ModalContent = () => { z.object({ name: z .string() + .trim() .min(1, LL.form.error.required()) .min(4, LL.form.error.minimumLength()), }), diff --git a/web/src/pages/users/shared/modals/RenameAuthenticationKeyModal/RenameAuthenticationKeyModal.tsx b/web/src/pages/users/shared/modals/RenameAuthenticationKeyModal/RenameAuthenticationKeyModal.tsx index d5482b7242..2bd74ae456 100644 --- a/web/src/pages/users/shared/modals/RenameAuthenticationKeyModal/RenameAuthenticationKeyModal.tsx +++ b/web/src/pages/users/shared/modals/RenameAuthenticationKeyModal/RenameAuthenticationKeyModal.tsx @@ -58,6 +58,7 @@ const ModalContent = () => { z.object({ name: z .string() + .trim() .min(1, LL.form.error.required()) .min(4, LL.form.error.minimumLength()), }), diff --git a/web/src/pages/wizard/components/WizardMapDevices/types.ts b/web/src/pages/wizard/components/WizardMapDevices/types.ts index 79fc971d68..884949dc9d 100644 --- a/web/src/pages/wizard/components/WizardMapDevices/types.ts +++ b/web/src/pages/wizard/components/WizardMapDevices/types.ts @@ -5,14 +5,14 @@ export const wizardMapDevicesSchema = (LL: TranslationFunctions) => z.object({ devices: z.array( z.object({ - wireguard_ips: z.array(z.string().min(1, LL.form.error.required())), + wireguard_ips: z.array(z.string().trim().min(1, LL.form.error.required())), user_id: z .number({ invalid_type_error: LL.form.error.required(), }) .min(1, LL.form.error.required()), - wireguard_pubkey: z.string().min(1, LL.form.error.required()), - name: z.string().min(1, LL.form.error.required()), + wireguard_pubkey: z.string().trim().min(1, LL.form.error.required()), + name: z.string().trim().min(1, LL.form.error.required()), }), ), }); diff --git a/web/src/pages/wizard/components/WizardNetworkConfiguration/WizardNetworkConfiguration.tsx b/web/src/pages/wizard/components/WizardNetworkConfiguration/WizardNetworkConfiguration.tsx index 56ae953817..caa6ef8530 100644 --- a/web/src/pages/wizard/components/WizardNetworkConfiguration/WizardNetworkConfiguration.tsx +++ b/web/src/pages/wizard/components/WizardNetworkConfiguration/WizardNetworkConfiguration.tsx @@ -101,23 +101,25 @@ export const WizardNetworkConfiguration = () => { const zodSchema = useMemo( () => z.object({ - name: z.string().min(1, LL.form.error.required()), + name: z.string().trim().min(1, LL.form.error.required()), address: z .string() + .trim() .min(1, LL.form.error.required()) .refine((value) => { return validateIpList(value, ',', true); }, LL.form.error.addressNetmask()), - endpoint: z.string().min(1, LL.form.error.required()), + endpoint: z.string().trim().min(1, LL.form.error.required()), port: z .number({ invalid_type_error: LL.form.error.invalid(), }) .max(65535, LL.form.error.portMax()) .nonnegative(), - allowed_ips: z.string(), + allowed_ips: z.string().trim(), dns: z .string() + .trim() .optional() .refine((val) => { if (val === '' || !val) { @@ -125,7 +127,7 @@ export const WizardNetworkConfiguration = () => { } return validateIpOrDomainList(val, ',', true); }, LL.form.error.allowedIps()), - allowed_groups: z.array(z.string().min(1, LL.form.error.minimumLength())), + allowed_groups: z.array(z.string().trim().min(1, LL.form.error.minimumLength())), keepalive_interval: z .number({ invalid_type_error: LL.form.error.invalid(), diff --git a/web/src/pages/wizard/components/WizardNetworkImport/WizardNetworkImport.tsx b/web/src/pages/wizard/components/WizardNetworkImport/WizardNetworkImport.tsx index 9a59cc496f..52c798c0ee 100644 --- a/web/src/pages/wizard/components/WizardNetworkImport/WizardNetworkImport.tsx +++ b/web/src/pages/wizard/components/WizardNetworkImport/WizardNetworkImport.tsx @@ -65,13 +65,14 @@ export const WizardNetworkImport = () => { const zodSchema = useMemo( () => z.object({ - name: z.string().min(1, LL.form.error.required()), + name: z.string().trim().min(1, LL.form.error.required()), endpoint: z .string() + .trim() .min(1, LL.form.error.required()) .refine((val) => validateIpOrDomain(val), LL.form.error.endpoint()), - fileName: z.string().min(1, LL.form.error.required()), - config: z.string().min(1, LL.form.error.required()), + fileName: z.string().trim().min(1, LL.form.error.required()), + config: z.string().trim().min(1, LL.form.error.required()), allowed_groups: z.array(z.string().min(1, LL.form.error.minimumLength())), }), [LL.form.error], diff --git a/web/src/shared/components/Layout/EnterpriseUpgradeToast/types.ts b/web/src/shared/components/Layout/EnterpriseUpgradeToast/types.ts index 6a646624e9..5e111a0ca7 100644 --- a/web/src/shared/components/Layout/EnterpriseUpgradeToast/types.ts +++ b/web/src/shared/components/Layout/EnterpriseUpgradeToast/types.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; export const enterpriseUpgradeToastMetaSchema = z.object({ - customId: z.string().min(1), + customId: z.string().trim().min(1), }); export type EnterpriseUpgradeToastMeta = z.infer; diff --git a/web/src/shared/components/Layout/VersionUpdateToast/types.ts b/web/src/shared/components/Layout/VersionUpdateToast/types.ts index e4a251bc58..8ea128bf9a 100644 --- a/web/src/shared/components/Layout/VersionUpdateToast/types.ts +++ b/web/src/shared/components/Layout/VersionUpdateToast/types.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; export const versionUpdateToastMetaSchema = z.object({ - customId: z.string().min(1), + customId: z.string().trim().min(1), }); export type VersionUpdateToastMeta = z.infer;