-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Feature Request
Add support for Pydantic's Annotated type with Field constraints in the Pydantic plugin.
Current State
The MVP implementation (v0.6.0) supports:
- Basic types (str, int, float, bool)
- Optional and default values
- Complex types (List, Dict, Set, Tuple)
- Existing Pydantic BaseModel instances
Requested Enhancement
Support Annotated with Field for constraints like:
from typing import Annotated
from pydantic import Field
sw = Switcher().plug("pydantic")
@sw
def create_user(
name: Annotated[str, Field(min_length=2, max_length=50)],
age: Annotated[int, Field(ge=0, le=120)],
email: Annotated[str, Field(pattern=r'^[\w\.-]+@[\w\.-]+\.\w+$')]
):
...Implementation Notes
- Extract
Fieldmetadata fromAnnotatedtypes - Pass constraints to dynamic Pydantic model creation
- Ensure error messages show which constraint was violated
Priority
Medium - This would make the plugin more powerful for data validation use cases.
Related
Part of the Pydantic plugin MVP+1 features discussed in initial implementation.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request