Skip to content

Commit

Permalink
feat(wip): fix path checker
Browse files Browse the repository at this point in the history
  • Loading branch information
outSH committed Jul 16, 2024
1 parent eaea4aa commit 28a12a5
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from "react";
import Box from "@mui/material/Box";
import TextField from "@mui/material/TextField";

const pathCheckRegex = /^\/[a-zA-Z][a-zA-Z0-9]*$/;
const emptyFormHelperText = "Field can't be empty";
const regularPathHelperText =
"Path under which the plugin will be available, must be unique withing GUI.";
Expand Down Expand Up @@ -30,9 +31,7 @@ export default function AppSetupForm({
const isInstanceNameEmptyError = !!!commonSetupValues.instanceName;
const isDescriptionEmptyError = !!!commonSetupValues.description;
const isPathEmptyError = !!!commonSetupValues.path;
const isPathInvalidError = !(
commonSetupValues.path.startsWith("/") && commonSetupValues.path.length > 1
);
const isPathInvalidError = !pathCheckRegex.test(commonSetupValues.path);
let pathHelperText = regularPathHelperText;
if (isPathEmptyError) {
pathHelperText = emptyFormHelperText;
Expand Down

0 comments on commit 28a12a5

Please sign in to comment.