Skip to content

Commit

Permalink
fix(chalice): fixed schemas field validator
Browse files Browse the repository at this point in the history
  • Loading branch information
tahayk committed Aug 13, 2024
1 parent fd7ec97 commit fa5f1f7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ee/api/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ python3-saml = "==1.16.0"
redis = "==5.1.0b6"
azure-storage-blob = "==12.22.0"
cachetools = "==5.4.0"
psycopg = {extras = ["pool", "binary"], version = "==3.2.1"}
psycopg = {extras = ["binary", "pool"], version = "==3.2.1"}
uvicorn = {extras = ["standard"], version = "==0.30.5"}
pydantic = {extras = ["email"], version = "==2.3.0"}
pydantic = {extras = ["email"], version = "==2.8.2"}
clickhouse-driver = {extras = ["lz4"], version = "==0.2.8"}

[dev-packages]
Expand Down
8 changes: 5 additions & 3 deletions ee/api/schemas/assist_stats_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pydantic import Field, field_validator

from .overrides import BaseModel, Enum, ORUnion
from .overrides import BaseModel


class AssistStatsAverage(BaseModel):
Expand Down Expand Up @@ -60,13 +60,15 @@ class AssistStatsSessionsRequest(BaseModel):
userId: Optional[int] = Field(default=None)

@field_validator("sort")
def validate_sort(self, v):
@classmethod
def validate_sort(cls, v):
if v not in assist_sort_options:
raise ValueError(f"Invalid sort option. Allowed options: {', '.join(assist_sort_options)}")
return v

@field_validator("order")
def validate_order(self, v):
@classmethod
def validate_order(cls, v):
if v not in ["desc", "asc"]:
raise ValueError("Invalid order option. Must be 'desc' or 'asc'.")
return v
Expand Down
4 changes: 2 additions & 2 deletions ee/api/schemas/schemas_ee.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from pydantic import Field, EmailStr, field_validator, model_validator

from . import schemas
from chalicelib.utils.TimeUTC import TimeUTC
from . import schemas
from .overrides import BaseModel, Enum, ORUnion
from .transformers_validators import remove_whitespace, remove_duplicate_values
from .transformers_validators import remove_whitespace


class Permissions(str, Enum):
Expand Down

0 comments on commit fa5f1f7

Please sign in to comment.