File size: 2,273 Bytes
ef1ad9e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from enum import Enum

from pydantic import BaseModel, EmailStr, Field, validator


class SignupSchema(BaseModel):
    firstName: str
    lastName: str
    email: str
    password: str
    phoneNumber: str
    NMLS: str
    lenderId: int

    @validator("lenderId")
    def id_must_be_positive(cls, v):
        if v <= 0:
            raise ValueError("lenderId must be a positive integer")
        return v

    @validator("firstName", "lastName")
    def name_must_not_be_empty(cls, v):
        if not v.strip():
            raise ValueError("Name cannot be empty")
        return v

    @validator("email")
    def email_must_be_valid(cls, v):
        if not v:
            raise ValueError("Email cannot be empty")
        if "@" not in v:
            raise ValueError("Invalid email format")
        return v

    @validator("password")
    def password_must_not_be_empty(cls, v):
        if not v:
            raise ValueError("Password cannot be empty")
        return v


class LoginSchema(BaseModel):
    email: EmailStr
    password: str

    @validator("email")
    def email_must_be_valid(cls, v):
        if not v:
            raise ValueError("Email cannot be empty")
        if "@" not in v:
            raise ValueError("Invalid email format")
        return v

    @validator("password")
    def password_must_not_be_empty(cls, v):
        if not v:
            raise ValueError("Password cannot be empty")
        return v


class Source(Enum):
    google = "google-oauth2"
    auth0 = "auth0"


class Roles(Enum):
    consumer = "consumer"
    loan_officer = "loan_officer"


class CheckFirstTimeUserSchema(BaseModel):
    user_id: str = Field("1", example="1", description="The unique identifier for the user.")
    source: Source = Field(
        ..., example="web", description="The source from where the user is accessing the application."
    )
    email: str = Field(
        "[email protected]", example="[email protected]", description="The email address of the user."
    )
    first_name: str = Field("John", example="John", description="The first name of the user.")
    last_name: str = Field("Doe", example="Doe", description="The last name of the user.")