Skip to content

Commit

Permalink
add: charactors to the vaild list for chat titles
Browse files Browse the repository at this point in the history
added common punctuation to the charactersValid
  • Loading branch information
dustinwloring1988 committed Dec 16, 2024
1 parent 0ee3736 commit 2d57bd2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/lib/hooks/useEditChatDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,16 @@ export function useEditChatDescription({
}

const lengthValid = trimmedDesc.length > 0 && trimmedDesc.length <= 100;
const characterValid = /^[a-zA-Z0-9\s]+$/.test(trimmedDesc);
// Allow letters, numbers, spaces, and common punctuation but exclude characters that could cause issues
const characterValid = /^[a-zA-Z0-9\s\-_.,!?()[\]{}'"]+$/.test(trimmedDesc);

if (!lengthValid) {
toast.error('Description must be between 1 and 100 characters.');
return false;
}

if (!characterValid) {
toast.error('Description can only contain alphanumeric characters and spaces.');
toast.error('Description can only contain letters, numbers, spaces, and basic punctuation.');
return false;
}

Expand Down

0 comments on commit 2d57bd2

Please sign in to comment.