1 export default function validTitle(title?: string): boolean {
2 // Initial title is null, minimum length is taken care of by textarea's minLength={3}
3 if (!title || title.length < 3) return true;
6 Test if the Title is in a valid format:
7 (?=.*\S.*) checks if the title consists of only whitespace characters
8 (?=^[^\r\n]+$) checks if the title contains newlines
10 const regex = new RegExp(/(?=(.*\S.*))(?=^[^\r\n]+$)/, "g");
12 return regex.test(title);