Skip to content

Commit

Permalink
Pydantic Config
Browse files Browse the repository at this point in the history
  • Loading branch information
loechel committed Apr 18, 2024
1 parent 28bf556 commit d5003b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/edutap/wallet_google/modelbase.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
from pydantic import BaseModel
from pydantic import ConfigDict


class GoogleWalletModel(BaseModel):
"""
Base model for all Google Wallet models.
"""

model_config = ConfigDict(
extra="forbid",
use_enum_values=True,
)


class GoogleWalletWithIdModel(GoogleWalletModel):
"""
Expand Down
4 changes: 2 additions & 2 deletions src/edutap/wallet_google/models/primitives/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ def __new__(cls: type["CamelCaseAliasEnum"], value: str) -> "CamelCaseAliasEnum"
camel = "".join(
[(x.capitalize() if count != 0 else x) for count, x in enumerate(parts)]
)

# create a second object with the camelcase name
# creating an alias only does not work out since
# pydantic checks for the value in the enum and not only the name
camel_obj= object.__new__(cls)
camel_obj = object.__new__(cls)
camel_obj._value_ = camel
cls._value2member_map_[camel] = camel_obj
cls._member_map_[camel] = camel_obj
Expand Down

0 comments on commit d5003b1

Please sign in to comment.