Pydantic Migration Guides

Fix Pydantic v2 @validator deprecation warnings

Replace simple @validator usage with @field_validator in the safe Pydantic v2 subset.

Start here

The safe first move

Use @field_validator for simple field validators, but stop when the validator depends on values, field, config, each_item, or always.

Stop before automation when: values, field, or config parameters. each_item=True or always=True behavior.

Target shape

from pydantic import BaseModel, field_validator

class User(BaseModel):
    @field_validator("email")
    @classmethod
    def clean_email(cls, value):
        return value.lower()

Repo fit check

Want to know if your repo has this pattern?

Run the matching scanner locally first. Read the free findings and manual alternatives; consider paid cleanup only if supported patterns repeat enough to justify the price.

  • Local scan; no repository upload.
  • Supported findings are separated from manual-review findings.
  • Buy only when the repeated pattern is worth automating.
Run the Pydantic scan first View example report See when to buy
Example scan summary
supported_findings: 38
manual_review_findings: 6
files_uploaded: 0
confidence: reviewable

Why this page exists

Fix Pydantic v2 @validator deprecation warnings

Simple validators are safe cleanup; signature-heavy validators need review.

Direct answer

What changes

Use @field_validator for simple field validators, but stop when the validator depends on values, field, config, each_item, or always.

Example

Before and after

Before

from pydantic import BaseModel, validator

class User(BaseModel):
    @validator("email")
    def clean_email(cls, value):
        return value.lower()

After

from pydantic import BaseModel, field_validator

class User(BaseModel):
    @field_validator("email")
    @classmethod
    def clean_email(cls, value):
        return value.lower()

Decision path

If this repeats across the repo, open the evaluation pages next.

The cleanup pack is strongest when the repo still uses direct pydantic imports and a clean validator/settings/config subset.

  • The repo has direct pydantic or pydantic.v1 imports, BaseSettings usage, safe Config blocks, or simple validators.
  • The migration pain is repetitive v1-to-v2 cleanup, not a custom semantic rewrite.
  • If the scan output is ambiguous, review its findings and upstream guidance. Do not buy expecting unsupported cases to be resolved.

Typical symptoms

  • Test output includes PydanticDeprecatedSince20 warnings.
  • Validators are simple field-level cleanup functions.
  • Some validators have extra signature arguments.

What the product covers

  • Simple @validator to @field_validator rewrites.
  • Import cleanup for field_validator.
  • Manual-review findings for signature-heavy cases.

Manual-review boundary

  • values, field, or config parameters.
  • each_item=True or always=True behavior.
  • Validators that change model-level semantics.

FAQ

Fast answers before you decide

What is the safest fix for PydanticDeprecatedSince20 validator field_validator?

Use @field_validator for simple field validators, but stop when the validator depends on values, field, config, each_item, or always.

Can PydanticDeprecatedSince20 validator field_validator be automated?

Automate only the supported subset: Simple @validator to @field_validator rewrites. Import cleanup for field_validator. Manual-review findings for signature-heavy cases. Keep these cases in manual review: values, field, or config parameters. each_item=True or always=True behavior. Validators that change model-level semantics.

When should I buy Pydantic v1 to v2 Migration Cleanup Pack?

Use Pydantic v1 to v2 Migration Cleanup Pack only when this pattern repeats across enough files that manual cleanup is still costly. Use the free report and upstream guide to evaluate fit. Buy only if repeated supported edits justify the price; no paid assessment is required.

Purchase fit

Choose the lowest-risk next step.

One matching page is not enough by itself. Run the local scan, then buy only when the same supported pattern appears often enough to matter.

Buy if

  • The repo has direct pydantic or pydantic.v1 imports, BaseSettings usage, safe Config blocks, or simple validators.
  • The migration pain is repetitive v1-to-v2 cleanup, not a custom semantic rewrite.
  • The team accepts manual-review findings for alias-heavy imports and signature-heavy validators.

What the workflow includes

  • Installable local CLI workflow, not a hosted black box.
  • Supported validator, settings, import, and config rewrites.
  • Demo report, public proof, coverage notes, rollback checklist, and buyer terms.

Before checkout

  • Stripe Checkout handles secure payment and receipts.
  • Download your purchased ZIP after payment.
  • Runs locally; no hosted API, repo upload, or production credentials needed.
  • The free report includes the evidence needed to evaluate fit. Paid summary and template add-ons are optional.
  • 14-day refund review for published-scope or delivery mismatches.