GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python/examples/pydantic-validation at master · flypythoncom/python

Expand file tree

/

pydantic-validation

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

pydantic-validation

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
solution
solution
 
 
starter
starter
 
 
tests
tests
 
 
README.md
README.md
 
 
README_cn.md
README_cn.md
 
 
TASK.md
TASK.md
 
 
TASK_cn.md
TASK_cn.md
 
 
verify.py
verify.py
 
 

README.md

id example-pydantic-validation
type example
title Validate Untrusted Boundary Payloads
summary Parse, sanitize, and validate messy external payloads with field normalization and structured error contracts.
lang en-US
content_version 1
status reviewed
reviewed_on 2026-09-02

Validate Untrusted Boundary Payloads

This exercise is standard-library only by design: you hand-roll the normalization and validation mechanics that a schema library such as Pydantic automates, so the boundary rules stay visible. In production, reach for Pydantic — see the catalog's Pydantic documentation entry.

External payloads from webhooks, mobile clients, and LLM tool calls are untrusted. They frequently arrive with mixed camelCase and snake_case keys, dirty currency strings, or invalid enum states. A production boundary validator must sanitize valid variations and return structured errors without crashing.

python examples/pydantic-validation/verify.py starter --expect-failure
python examples/pydantic-validation/verify.py solution

The first command reports the expected failures from the naive starter. The second verifies the robust solution. Give TASK.md to a coding agent, ask it to fix only starter/validator.py, and run:

python examples/pydantic-validation/verify.py starter

See this example on flypython.com: the browsable contract, step-by-step walkthrough, and current review state.

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.