summaryrefslogtreecommitdiff
path: root/src/api/models/user.ts
blob: ac59e2bfc3e8b99ae93b0e348e56d0e19cf86ea6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
const collection = global.db.collection('users');

collection.createIndex('username');
collection.createIndex('token');

export default collection;

export function validateUsername(username: string): boolean {
	return /^[a-zA-Z0-9\-]{3,20}$/.test(username);
}

export function isValidBirthday(birthday: string): boolean {
	return /^([0-9]{4})\-([0-9]{2})-([0-9]{2})$/.test(birthday);
}