Skip to content

Commit

Permalink
Fixed issue in Admin model to allow the 'email' field to be either nu…
Browse files Browse the repository at this point in the history
…ll or excluded
  • Loading branch information
DCMattyG committed Oct 10, 2023
1 parent 2571910 commit b37ea4f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions engine/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,13 @@ class Admin(BaseModel):
name: str
email: Optional[EmailStr] = None
id: UUID

@model_validator(mode='before')
@classmethod
def check_email(cls, data: Any) -> Any:
if isinstance(data, dict):
if 'type' in data and 'email' in data:
if data['type'] == "Principal":
if data['type'] == "Principal" and data['email'] is not None:
raise ValueError("email should not be set for 'principal' type")
if 'type' in data and 'email' not in data:
if data['type'] == "User":
Expand Down

0 comments on commit b37ea4f

Please sign in to comment.