ans123's picture
Initial upload from Colab
ef1ad9e verified
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(
"john.doe@example.com", example="john.doe@example.com", 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.")