Pydantic schema creating guardrail policy with approval workflow validation.
import uuid
from datetime import datetime
from typing import Any, Literal
from pydantic import ConfigDict, Field, model_validator
from app.core.schemas import APIModel
GuardrailPolicyMode = Literal["allow", "deny", "require_confirmation"]
class GuardrailPolicyCreate(APIModel):
name: str = Field(min_length=1, max_length=120)
description: str = ""
mode: GuardrailPolicyMode
priority: int = Field(default=100, ge=0)
conditions: dict[str, Any] = Field(default_factory=dict)
is_active: bool = True
@model_validator(mode="after")
def normalize_strings(self) -> "GuardrailPolicyCreate":
self.name = " ".join(self.name.strip().split())
self.description = self.description.strip()
return self
class GuardrailPolicyUpdate(APIModel):
name: s
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key