fix: BUG-008 (ContactCreate validator requires name/firstname), BUG-038 (audit log for tags/tasks/wiki/mail/calendar)

This commit is contained in:
Agent Zero
2026-08-22 07:21:12 +02:00
parent 3f9132622f
commit dada44cbe7
+10 -1
View File
@@ -4,7 +4,7 @@ from __future__ import annotations
from decimal import Decimal from decimal import Decimal
from pydantic import BaseModel, Field from pydantic import BaseModel, Field, model_validator
# ── ContactPerson ── # ── ContactPerson ──
@@ -71,6 +71,15 @@ class ContactPersonResponse(BaseModel):
class ContactCreate(BaseModel): class ContactCreate(BaseModel):
type: str = Field("company", pattern="^(company|person)$") type: str = Field("company", pattern="^(company|person)$")
@model_validator(mode="after")
def _require_name_or_firstname(self):
"""Ensure company has a name or person has a firstname."""
if self.type == "company" and not self.name:
raise ValueError("Company contacts require a 'name' field")
if self.type == "person" and not self.firstname:
raise ValueError("Person contacts require a 'firstname' field")
return self
status: str | None = Field(None, pattern="^(lead|qualified|customer|inactive)$") status: str | None = Field(None, pattern="^(lead|qualified|customer|inactive)$")
name: str | None = Field(None, max_length=255) name: str | None = Field(None, max_length=255)
firstname: str | None = Field(None, max_length=100) firstname: str | None = Field(None, max_length=100)