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

194
Views
Validate nested model

Using the example below, how can I restrict the "contents" of a recipe to only be one or multiple instances of the following:

    {
      "quantity": "4",
      "unit": "slices",
      "ingredient": "bacon"
    }

Example JSON

{
  "name": "Big Breakfast",
  "note": "Something to eat every friday",
  "star": true,
  "contents": [
    {
      "quantity": "4",
      "unit": "slices",
      "ingredient": "bacon"
    },
    {
      "quantity": "2",
      "unit": "",
      "ingredient": "eggs"
    },
    {
      "quantity": "2",
      "unit": "slices",
      "ingredient": "cheese"
    }
  ]
}

Schema

class RecipeBase(BaseModel):
    name: str
    note: Optional[str]
    star: Optional[bool] = False
    contents: Optional[List[dict]] = []

    class Config:
        orm_mode = True
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!