Parsing & 422s

Two ways data becomes a model

So far you've built models with keyword arguments: SignupRequest(email=..., password=..., name=...). But data usually arrives as a dict โ€” parsed from JSON that came over the wire. Pydantic's model_validate builds a model straight from a dict, running the exact same checks.

SignupRequest.model_validate({"email": "ana@example.com", "password": "longenough", "name": "Ana"}) โ€” same validation, dict in instead of keywords in.