From c0c30163c3f6f34e1652890563337c141080babe Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Wed, 6 Mar 2024 23:44:05 +0100 Subject: [PATCH] Validate device name (#642) allow only - 16 chars - letters - numbers - "-" - "_" --- src/components/settings/DeviceSetting.tsx | 2 ++ src/i18n/locale/en.json | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/components/settings/DeviceSetting.tsx b/src/components/settings/DeviceSetting.tsx index 094fe401..b1c6a5ed 100644 --- a/src/components/settings/DeviceSetting.tsx +++ b/src/components/settings/DeviceSetting.tsx @@ -71,6 +71,8 @@ export const DeviceSetting = () => { }} valueInfos={devices.map((device) => [device, { mutable: false, deletable: device !== DEFAULT_DEVICE }])} addItemButtonTitle={t('global.button.create')} + validateItem={(device) => device.length <= 16 && !!device.match(/^[a-zA-Z0-9\-_]+$/g)} + placeholder={t('settings.device.label.placeholder')} />