Skip to content

Commit

Permalink
feat: added the logic and alert for resource names regex
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushgml committed May 31, 2023
1 parent b7e36c2 commit d3b27b9
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ const TemplateForm: React.FC<IProps> = props => {
const setFormData = useCallback(
(formIndex: number, formData: Record<string, Primitive>) => {
const newFormDataList = currentFormDataList.slice(0);
if (newFormDataList[0].name && !/^[a-z0-9]([-a-z0-9]*[a-z0-9])?$/.test(newFormDataList[0].name.toString())) {
alert(
"Name must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character"
);
return;
}
newFormDataList.splice(formIndex, 1, formatFormData(formData));
setCurrentFormDataList(newFormDataList);
setActiveFormIndex(formIndex + 1);
Expand Down

0 comments on commit d3b27b9

Please sign in to comment.