From 707142a5e6cea0d63e288a9c3c458be3e500ec62 Mon Sep 17 00:00:00 2001
From: Sue Ann Kim <38238542+wackyleo459@users.noreply.github.com>
Date: Tue, 23 Aug 2022 00:22:05 -0700
Subject: [PATCH] Device Alias form has validation factors: (#813)
* Device Alias form validation has validation factors:
- Max length of 30 characters
- Name can not start with a space
- Name should not contain special characters (only alphanumeric characters, underscore character, and hyphen or space in the middle are allowed)
* Lint Formatting
* Regex pattern explained.
Better formatting and js logic
---
.../addDevice/manage/addDevicePickAlias.ts | 20 +++++++++++++
.../src/flows/addDevice/validateAlias.ts | 25 ++++++++++++++++
src/frontend/src/flows/register.ts | 29 ++++++++++++++++++-
3 files changed, 73 insertions(+), 1 deletion(-)
create mode 100644 src/frontend/src/flows/addDevice/validateAlias.ts
diff --git a/src/frontend/src/flows/addDevice/manage/addDevicePickAlias.ts b/src/frontend/src/flows/addDevice/manage/addDevicePickAlias.ts
index 041dd4e739..d50293f45c 100644
--- a/src/frontend/src/flows/addDevice/manage/addDevicePickAlias.ts
+++ b/src/frontend/src/flows/addDevice/manage/addDevicePickAlias.ts
@@ -1,5 +1,10 @@
import { html, render } from "lit-html";
import { initLogout, logoutSection } from "../../../components/logout";
+import { validateAlias } from "../validateAlias";
+// Regex Pattern for input: All characters, must be alphabet or number
+// Can have hyphen(s), space(s) or underscore(s) in the middle.
+// Good examples: "2019_macbook", "2019-Macbook", "2019 Macbook"
+// Bad examples: "2019 macbook!", "2010 macbook_", "space trails at end "
const pageContent = () => html`