UNPKG

@authduo/authduo

Version:

Free User-sovereign Authentication for the World

18 lines 551 B
export const maxNameLength = 24; export function validName(name) { if (name !== name.trim()) return false; const spaceless = name.replaceAll(" ", ""); return [ typeof name === "string", name.length >= 1, name.length <= maxNameLength, // no consecutive spaces !/[ ]{2,}/u.test(name), // no whitespace except ordinary spaces !/\s/.test(spaceless), // no control chars !/\p{Z}\p{C}/u.test(spaceless), ].every(v => v); } //# sourceMappingURL=validation.js.map