2021-07-27 16:37:01 +02:00
|
|
|
import { MAX_USERNAME_LENGTH } from "../Enum/EnvironmentVariable";
|
2021-04-07 14:09:45 +02:00
|
|
|
|
2020-10-20 16:39:23 +02:00
|
|
|
export interface CharacterTexture {
|
2021-07-27 16:37:01 +02:00
|
|
|
id: number;
|
|
|
|
level: number;
|
|
|
|
url: string;
|
|
|
|
rights: string;
|
2020-10-20 16:39:23 +02:00
|
|
|
}
|
|
|
|
|
2021-04-07 14:09:45 +02:00
|
|
|
export const maxUserNameLength: number = MAX_USERNAME_LENGTH;
|
|
|
|
|
2021-05-26 17:07:07 +02:00
|
|
|
export function isUserNameValid(value: unknown): boolean {
|
2021-06-21 17:58:04 +02:00
|
|
|
return typeof value === "string" && value.length > 0 && value.length <= maxUserNameLength && /\S/.test(value);
|
2021-04-07 14:09:45 +02:00
|
|
|
}
|
|
|
|
|
2021-04-13 01:41:26 +02:00
|
|
|
export function areCharacterLayersValid(value: string[] | null): boolean {
|
|
|
|
if (!value || !value.length) return false;
|
2021-04-07 14:09:45 +02:00
|
|
|
for (let i = 0; i < value.length; i++) {
|
|
|
|
if (/^\w+$/.exec(value[i]) === null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-10-12 16:23:07 +02:00
|
|
|
export class LocalUser {
|
2021-09-30 16:14:55 +02:00
|
|
|
constructor(
|
|
|
|
public readonly uuid: string,
|
|
|
|
public textures: CharacterTexture[],
|
|
|
|
public email: string | null = null
|
|
|
|
) {}
|
2020-10-20 16:39:23 +02:00
|
|
|
}
|