from snek.system.model import BaseModel, ModelField


class UserModel(BaseModel):

    username = ModelField(
        name="username",
        required=True,
        min_length=2,
        max_length=20,
        regex=r"^[a-zA-Z0-9_-+/]+$",
    )
    nick = ModelField(
        name="nick",
        required=True,
        min_length=2,
        max_length=20,
        regex=r"^[a-zA-Z0-9_-+/]+$",
    )
    color = ModelField(
        name ="color",
        required=True,
        regex=r"^#[0-9a-fA-F]{6}$",
        kind=str
    )
    email = ModelField(
        name="email",
        required=False,
        regex=r"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$",
    )
    password = ModelField(name="password", required=True, min_length=1)

    last_ping = ModelField(name="last_ping", required=False, kind=str)
