Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
Pydantic JSON validation

Currently i am working on a sample project using pydantic and starlette. This is code from main file:

async def submit(request):
response = await request.json()
resume = Resume(**response)
JsonResponse({"Hello":"World"})

Code from Validation file:

class Basics(BaseModel):
name: str
label: str
image: str
email: str
phone: str
url: str
summary: str
location: Location
profiles: List[Profiles]

@validator('email')
def email_validation(cls, v):
    regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b'
    if (re.fullmatch(regex, v)):
        return True
    else: 
        raise ValueError("Email not valid")

Class Basics is a child class of class Resume. When the regex doesnt match it correctly raises a value error and internal server error is displayed in postman. But how do I return this error or some statement to postman other and prevent internal server error?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!