|
from pydantic import BaseModel, EmailStr, validator
|
|
from enum import Enum
|
|
|
|
|
|
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
|
|
source: Source
|
|
email: str
|
|
first_name: str
|
|
last_name: str
|
|
|