37 lines
794 B
TypeScript
37 lines
794 B
TypeScript
import type { genericValidation } from "#types/lib";
|
|
|
|
const nameRestrictions: genericValidation = {
|
|
length: { min: 3, max: 20 },
|
|
regex: /^[\p{L}\p{N}._-]+$/u,
|
|
};
|
|
|
|
const displayNameRestrictions: genericValidation = {
|
|
length: { min: 1, max: 32 },
|
|
regex: /^[\p{L}\p{N}\p{M}\p{S}\p{P}\s]+$/u,
|
|
};
|
|
|
|
const forbiddenDisplayNamePatterns = [
|
|
/[\r\n\t]/,
|
|
/\s{3,}/,
|
|
/^\s|\s$/,
|
|
/#everyone|#here/i,
|
|
/\p{Cf}/u,
|
|
/\p{Cc}/u,
|
|
];
|
|
|
|
const passwordRestrictions: genericValidation = {
|
|
length: { min: 12, max: 64 },
|
|
regex: /^(?=.*\p{Ll})(?=.*\p{Lu})(?=.*\d)(?=.*[^\w\s]).{12,64}$/u,
|
|
};
|
|
|
|
const emailRestrictions: { regex: RegExp } = {
|
|
regex: /^[^\s#]+#[^\s#]+\.[^\s#]+$/,
|
|
};
|
|
|
|
export {
|
|
nameRestrictions,
|
|
displayNameRestrictions,
|
|
forbiddenDisplayNamePatterns,
|
|
passwordRestrictions,
|
|
emailRestrictions,
|
|
};
|