Skip to content

Commit

Permalink
Update arbitrary class doc example using Annotated instead of constr (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
0x00cl committed Nov 6, 2023
1 parent d2abc7b commit 185e03a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docs/concepts/models.md
Expand Up @@ -227,8 +227,9 @@ from typing import List
from sqlalchemy import Column, Integer, String
from sqlalchemy.dialects.postgresql import ARRAY
from sqlalchemy.orm import declarative_base
from typing_extensions import Annotated

from pydantic import BaseModel, ConfigDict, constr
from pydantic import BaseModel, ConfigDict, StringConstraints

Base = declarative_base()

Expand All @@ -246,9 +247,9 @@ class CompanyModel(BaseModel):
model_config = ConfigDict(from_attributes=True)

id: int
public_key: constr(max_length=20)
name: constr(max_length=63)
domains: List[constr(max_length=255)]
public_key: Annotated[str, StringConstraints(max_length=20)]
name: Annotated[str, StringConstraints(max_length=63)]
domains: List[Annotated[str, StringConstraints(max_length=255)]]


co_orm = CompanyOrm(
Expand Down

0 comments on commit 185e03a

Please sign in to comment.